mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-09-22 00:00:50 +00:00
fix(disk): keep disk info when df exits with errors
df still prints valid filesystems when a mount point cannot be queried (for example a stale FUSE mount), but exits non-zero. The dashboard and the disk alert discarded the whole output in that case, so no disk was displayed. Keep using the output whenever it is not empty. Refs #13864.
This commit is contained in:
@@ -382,7 +382,7 @@ func executeDiskCommand() (string, error) {
|
||||
cmdMgr2 := cmd.NewCommandMgr(cmd.WithTimeout(1 * time.Second))
|
||||
stdout, err = cmdMgr2.RunWithStdout("df", "-lhT", "-P")
|
||||
}
|
||||
if err != nil {
|
||||
if err != nil && strings.TrimSpace(stdout) == "" {
|
||||
return stdout, err
|
||||
}
|
||||
var lines []string
|
||||
|
||||
@@ -469,7 +469,7 @@ func loadDiskInfo() []dto.DiskInfo {
|
||||
cmd.PipeCommand{Name: "df", Args: []string{"-lhT", "-P"}},
|
||||
cmd.PipeCommand{Name: "awk", Args: []string{format}},
|
||||
)
|
||||
if err != nil {
|
||||
if err != nil && strings.TrimSpace(stdout) == "" {
|
||||
return datas
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user