Improve disk UI and build performance
This commit is contained in:
@@ -2,6 +2,7 @@ package watcher
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"sync"
|
||||
@@ -121,22 +122,17 @@ func (w *Watcher) probe() {
|
||||
}
|
||||
|
||||
func discoverDisks(root string) map[string]disk.DiskInfo {
|
||||
candidates := []string{root}
|
||||
|
||||
if entries, err := filepath.Glob(filepath.Join(root, "*")); err == nil {
|
||||
for _, path := range entries {
|
||||
candidates = append(candidates, path)
|
||||
}
|
||||
entries, err := os.ReadDir(root)
|
||||
if err != nil {
|
||||
return map[string]disk.DiskInfo{}
|
||||
}
|
||||
|
||||
disks := make(map[string]disk.DiskInfo)
|
||||
seen := make(map[string]struct{}, len(candidates))
|
||||
for _, mountPath := range candidates {
|
||||
if _, ok := seen[mountPath]; ok {
|
||||
for _, entry := range entries {
|
||||
if !entry.IsDir() {
|
||||
continue
|
||||
}
|
||||
seen[mountPath] = struct{}{}
|
||||
|
||||
mountPath := filepath.Join(root, entry.Name())
|
||||
info, _ := disk.Probe(mountPath)
|
||||
if info.State == disk.DiskAbsent {
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user