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