Fix empty disk mount detection

This commit is contained in:
2026-04-23 22:58:07 +03:00
parent e7917b41b5
commit 0afc1d761b
2 changed files with 13 additions and 5 deletions

View File

@@ -5,6 +5,7 @@ import (
"os"
"path/filepath"
"sort"
"strings"
"sync"
"time"
@@ -122,14 +123,15 @@ func (w *Watcher) probe() {
}
func discoverDisks(root string) map[string]disk.DiskInfo {
disks := make(map[string]disk.DiskInfo)
entries, err := os.ReadDir(root)
if err != nil {
return map[string]disk.DiskInfo{}
return disks
}
disks := make(map[string]disk.DiskInfo)
for _, entry := range entries {
if !entry.IsDir() {
if !entry.IsDir() || strings.HasPrefix(entry.Name(), ".") {
continue
}
mountPath := filepath.Join(root, entry.Name())
@@ -139,5 +141,12 @@ func discoverDisks(root string) map[string]disk.DiskInfo {
}
disks[mountPath] = info
}
// If no child mountpoints were detected, the disk may be mounted directly at root.
if len(disks) == 0 {
if info, _ := disk.Probe(root); info.State != disk.DiskAbsent {
disks[root] = info
}
}
return disks
}