mirror of
https://github.com/glanceapp/glance.git
synced 2025-06-21 10:27:45 +02:00
Maybe fix for missing mountpoint info
This commit is contained in:
parent
50dae22ff4
commit
a3bc133bcb
@ -227,22 +227,24 @@ func Collect(req *SystemInfoRequest) (*SystemInfo, []error) {
|
||||
}
|
||||
}
|
||||
|
||||
filesystems, err := disk.Partitions(false)
|
||||
if err == nil {
|
||||
for _, fs := range filesystems {
|
||||
mpReq, ok := req.Mountpoints[fs.Mountpoint]
|
||||
addedMountpoints := map[string]struct{}{}
|
||||
addMountpointInfo := func(requestedPath string, mpReq MointpointRequest) {
|
||||
if _, exists := addedMountpoints[requestedPath]; exists {
|
||||
return
|
||||
}
|
||||
|
||||
isHidden := req.HideMountpointsByDefault
|
||||
if ok && mpReq.Hide != nil {
|
||||
if mpReq.Hide != nil {
|
||||
isHidden = *mpReq.Hide
|
||||
}
|
||||
if isHidden {
|
||||
continue
|
||||
return
|
||||
}
|
||||
|
||||
usage, err := disk.Usage(fs.Mountpoint)
|
||||
usage, err := disk.Usage(requestedPath)
|
||||
if err == nil {
|
||||
mpInfo := MountpointInfo{
|
||||
Path: fs.Mountpoint,
|
||||
Path: requestedPath,
|
||||
Name: mpReq.Name,
|
||||
TotalMB: usage.Total / 1024 / 1024,
|
||||
UsedMB: usage.Used / 1024 / 1024,
|
||||
@ -250,13 +252,26 @@ func Collect(req *SystemInfoRequest) (*SystemInfo, []error) {
|
||||
}
|
||||
|
||||
info.Mountpoints = append(info.Mountpoints, mpInfo)
|
||||
addedMountpoints[requestedPath] = struct{}{}
|
||||
} else {
|
||||
addErr(fmt.Errorf("getting filesystem usage for %s: %v", fs.Mountpoint, err))
|
||||
addErr(fmt.Errorf("getting filesystem usage for %s: %v", requestedPath, err))
|
||||
}
|
||||
}
|
||||
|
||||
if !req.HideMountpointsByDefault {
|
||||
filesystems, err := disk.Partitions(false)
|
||||
if err == nil {
|
||||
for _, fs := range filesystems {
|
||||
addMountpointInfo(fs.Mountpoint, req.Mountpoints[fs.Mountpoint])
|
||||
}
|
||||
} else {
|
||||
addErr(fmt.Errorf("getting filesystems: %v", err))
|
||||
}
|
||||
}
|
||||
|
||||
for mountpoint, mpReq := range req.Mountpoints {
|
||||
addMountpointInfo(mountpoint, mpReq)
|
||||
}
|
||||
|
||||
sort.Slice(info.Mountpoints, func(a, b int) bool {
|
||||
return info.Mountpoints[a].UsedPercent > info.Mountpoints[b].UsedPercent
|
||||
|
Loading…
x
Reference in New Issue
Block a user