mirror of
https://github.com/tw93/Mole.git
synced 2026-02-16 15:18:39 +00:00
no longer land in a meaningless Volumes
This commit is contained in:
BIN
bin/analyze-go
BIN
bin/analyze-go
Binary file not shown.
@@ -21,8 +21,8 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/cespare/xxhash/v2"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"golang.org/x/sync/singleflight"
|
||||
)
|
||||
|
||||
@@ -444,14 +444,41 @@ func createOverviewEntries() []dirEntry {
|
||||
dirEntry{name: "System Library", path: "/Library", isDir: true, size: -1},
|
||||
)
|
||||
|
||||
// Add Volumes if exists
|
||||
if _, err := os.Stat("/Volumes"); err == nil {
|
||||
// Add Volumes shortcut only when it contains real mounted folders (e.g., external disks)
|
||||
if hasUsefulVolumeMounts("/Volumes") {
|
||||
entries = append(entries, dirEntry{name: "Volumes", path: "/Volumes", isDir: true, size: -1})
|
||||
}
|
||||
|
||||
return entries
|
||||
}
|
||||
|
||||
func hasUsefulVolumeMounts(path string) bool {
|
||||
entries, err := os.ReadDir(path)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, entry := range entries {
|
||||
name := entry.Name()
|
||||
// Skip hidden control entries for Spotlight/TimeMachine etc.
|
||||
if strings.HasPrefix(name, ".") {
|
||||
continue
|
||||
}
|
||||
|
||||
info, err := os.Lstat(filepath.Join(path, name))
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if info.Mode()&fs.ModeSymlink != 0 {
|
||||
continue // Ignore the synthetic MacintoshHD link
|
||||
}
|
||||
if info.IsDir() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *model) hydrateOverviewEntries() {
|
||||
m.entries = createOverviewEntries()
|
||||
if m.overviewSizeCache == nil {
|
||||
|
||||
Reference in New Issue
Block a user