mirror of
https://github.com/tw93/Mole.git
synced 2026-02-16 02:36:12 +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) {
|
func TestLoadCacheExpiresWhenDirectoryChanges(t *testing.T) {
|
||||||
home := t.TempDir()
|
home := t.TempDir()
|
||||||
t.Setenv("HOME", home)
|
t.Setenv("HOME", home)
|
||||||
|
|||||||
@@ -5,13 +5,11 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/fs"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"slices"
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -236,32 +234,6 @@ func createOverviewEntries() []dirEntry {
|
|||||||
return entries
|
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() {
|
func (m *model) hydrateOverviewEntries() {
|
||||||
m.entries = createOverviewEntries()
|
m.entries = createOverviewEntries()
|
||||||
if m.overviewSizeCache == nil {
|
if m.overviewSizeCache == nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user