@@ -227,35 +227,50 @@ func Collect(req *SystemInfoRequest) (*SystemInfo, []error) {
227227 }
228228 }
229229
230- filesystems , err := disk .Partitions (false )
231- if err == nil {
232- for _ , fs := range filesystems {
233- mpReq , ok := req .Mountpoints [fs .Mountpoint ]
234- isHidden := req .HideMountpointsByDefault
235- if ok && mpReq .Hide != nil {
236- isHidden = * mpReq .Hide
237- }
238- if isHidden {
239- continue
230+ addedMountpoints := map [string ]struct {}{}
231+ addMountpointInfo := func (requestedPath string , mpReq MointpointRequest ) {
232+ if _ , exists := addedMountpoints [requestedPath ]; exists {
233+ return
234+ }
235+
236+ isHidden := req .HideMountpointsByDefault
237+ if mpReq .Hide != nil {
238+ isHidden = * mpReq .Hide
239+ }
240+ if isHidden {
241+ return
242+ }
243+
244+ usage , err := disk .Usage (requestedPath )
245+ if err == nil {
246+ mpInfo := MountpointInfo {
247+ Path : requestedPath ,
248+ Name : mpReq .Name ,
249+ TotalMB : usage .Total / 1024 / 1024 ,
250+ UsedMB : usage .Used / 1024 / 1024 ,
251+ UsedPercent : uint8 (math .Min (usage .UsedPercent , 100 )),
240252 }
241253
242- usage , err := disk .Usage (fs .Mountpoint )
243- if err == nil {
244- mpInfo := MountpointInfo {
245- Path : fs .Mountpoint ,
246- Name : mpReq .Name ,
247- TotalMB : usage .Total / 1024 / 1024 ,
248- UsedMB : usage .Used / 1024 / 1024 ,
249- UsedPercent : uint8 (math .Min (usage .UsedPercent , 100 )),
250- }
254+ info .Mountpoints = append (info .Mountpoints , mpInfo )
255+ addedMountpoints [requestedPath ] = struct {}{}
256+ } else {
257+ addErr (fmt .Errorf ("getting filesystem usage for %s: %v" , requestedPath , err ))
258+ }
259+ }
251260
252- info .Mountpoints = append (info .Mountpoints , mpInfo )
253- } else {
254- addErr (fmt .Errorf ("getting filesystem usage for %s: %v" , fs .Mountpoint , err ))
261+ if ! req .HideMountpointsByDefault {
262+ filesystems , err := disk .Partitions (false )
263+ if err == nil {
264+ for _ , fs := range filesystems {
265+ addMountpointInfo (fs .Mountpoint , req .Mountpoints [fs .Mountpoint ])
255266 }
267+ } else {
268+ addErr (fmt .Errorf ("getting filesystems: %v" , err ))
256269 }
257- } else {
258- addErr (fmt .Errorf ("getting filesystems: %v" , err ))
270+ }
271+
272+ for mountpoint , mpReq := range req .Mountpoints {
273+ addMountpointInfo (mountpoint , mpReq )
259274 }
260275
261276 sort .Slice (info .Mountpoints , func (a , b int ) bool {
0 commit comments