mirror of
https://github.com/tw93/Mole.git
synced 2026-02-11 12:59:16 +00:00
refactor(analyze): remove unused volume mount helper
This commit is contained in:
@@ -329,29 +329,6 @@ func TestIsCleanableDir(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestHasUsefulVolumeMounts(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
if hasUsefulVolumeMounts(root) {
|
||||
t.Fatalf("empty directory should not report useful mounts")
|
||||
}
|
||||
|
||||
hidden := filepath.Join(root, ".hidden")
|
||||
if err := os.Mkdir(hidden, 0o755); err != nil {
|
||||
t.Fatalf("create hidden dir: %v", err)
|
||||
}
|
||||
if hasUsefulVolumeMounts(root) {
|
||||
t.Fatalf("hidden entries should not count as useful mounts")
|
||||
}
|
||||
|
||||
mount := filepath.Join(root, "ExternalDrive")
|
||||
if err := os.Mkdir(mount, 0o755); err != nil {
|
||||
t.Fatalf("create mount dir: %v", err)
|
||||
}
|
||||
if !hasUsefulVolumeMounts(root) {
|
||||
t.Fatalf("expected useful mount when real directory exists")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadCacheExpiresWhenDirectoryChanges(t *testing.T) {
|
||||
home := t.TempDir()
|
||||
t.Setenv("HOME", home)
|
||||
|
||||
@@ -5,13 +5,11 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
@@ -236,32 +234,6 @@ func createOverviewEntries() []dirEntry {
|
||||
return entries
|
||||
}
|
||||
|
||||
func hasUsefulVolumeMounts(path string) bool {
|
||||
entries, err := os.ReadDir(path)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, entry := range entries {
|
||||
name := entry.Name()
|
||||
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