Skip to content

Commit

Permalink
优化 ai_false diskstate
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Mar 11, 2023
1 parent 366c7ac commit cc26eb1
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions plugin/ai_false/ai_false.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,23 +567,21 @@ func diskstate() (stateinfo []*status, err error) {
if err != nil {
return
}
stateinfo = make([]*status, len(parts))
for i, v := range parts {
stateinfo = make([]*status, 0, len(parts))
for _, v := range parts {
mp := v.Mountpoint
if strings.HasPrefix(mp, "/snap/") || strings.HasPrefix(mp, "/apex/") {
continue
}
diskusage, err := disk.Usage(mp)
usage := ""
precent := 0.0
if err != nil {
usage = err.Error()
} else {
usage = storagefmt(float64(diskusage.Used)) + " / " + storagefmt(float64(diskusage.Total))
precent = math.Round(diskusage.UsedPercent)
continue
}
stateinfo[i] = &status{
precent: precent,
stateinfo = append(stateinfo, &status{
precent: math.Round(diskusage.UsedPercent),
name: mp,
text: []string{usage},
}
text: []string{storagefmt(float64(diskusage.Used)) + " / " + storagefmt(float64(diskusage.Total))},
})
}
return stateinfo, nil
}
Expand Down

0 comments on commit cc26eb1

Please sign in to comment.