1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-16 22:49:12 +00:00

merge main

This commit is contained in:
Tw93
2025-11-18 10:09:45 +08:00
3 changed files with 55 additions and 49 deletions

Binary file not shown.

View File

@@ -21,8 +21,8 @@ import (
"syscall" "syscall"
"time" "time"
tea "github.com/charmbracelet/bubbletea"
"github.com/cespare/xxhash/v2" "github.com/cespare/xxhash/v2"
tea "github.com/charmbracelet/bubbletea"
"golang.org/x/sync/singleflight" "golang.org/x/sync/singleflight"
) )
@@ -51,30 +51,30 @@ var foldDirs = map[string]bool{
".hg": true, ".hg": true,
// JavaScript/Node // JavaScript/Node
"node_modules": true, "node_modules": true,
".npm": true, ".npm": true,
"_npx": true, // ~/.npm/_npx global cache "_npx": true, // ~/.npm/_npx global cache
"_cacache": true, // ~/.npm/_cacache "_cacache": true, // ~/.npm/_cacache
"_logs": true, // ~/.npm/_logs "_logs": true, // ~/.npm/_logs
"_locks": true, // ~/.npm/_locks "_locks": true, // ~/.npm/_locks
"_quick": true, // Quick install cache "_quick": true, // Quick install cache
"_libvips": true, // ~/.npm/_libvips "_libvips": true, // ~/.npm/_libvips
"_prebuilds": true, // ~/.npm/_prebuilds "_prebuilds": true, // ~/.npm/_prebuilds
"_update-notifier-last-checked": true, // npm update notifier "_update-notifier-last-checked": true, // npm update notifier
".yarn": true, ".yarn": true,
".pnpm-store": true, ".pnpm-store": true,
".next": true, ".next": true,
".nuxt": true, ".nuxt": true,
"bower_components": true, "bower_components": true,
".vite": true, ".vite": true,
".turbo": true, ".turbo": true,
".parcel-cache": true, ".parcel-cache": true,
".nx": true, ".nx": true,
".rush": true, ".rush": true,
"tnpm": true, // Taobao npm "tnpm": true, // Taobao npm
".tnpm": true, // Taobao npm cache ".tnpm": true, // Taobao npm cache
".bun": true, // Bun cache ".bun": true, // Bun cache
".deno": true, // Deno cache ".deno": true, // Deno cache
// Python // Python
"__pycache__": true, "__pycache__": true,
@@ -122,27 +122,27 @@ var foldDirs = map[string]bool{
".fleet": true, ".fleet": true,
// Cache directories // Cache directories
".cache": true, ".cache": true,
"__MACOSX": true, "__MACOSX": true,
".DS_Store": true, ".DS_Store": true,
".Trash": true, ".Trash": true,
"Caches": true, "Caches": true,
".Spotlight-V100": true, ".Spotlight-V100": true,
".fseventsd": true, ".fseventsd": true,
".DocumentRevisions-V100": true, ".DocumentRevisions-V100": true,
".TemporaryItems": true, ".TemporaryItems": true,
"$RECYCLE.BIN": true, "$RECYCLE.BIN": true,
".temp": true, ".temp": true,
".tmp": true, ".tmp": true,
"_temp": true, "_temp": true,
"_tmp": true, "_tmp": true,
".Homebrew": true, // Homebrew cache ".Homebrew": true, // Homebrew cache
".rustup": true, // Rust toolchain ".rustup": true, // Rust toolchain
".sdkman": true, // SDK manager ".sdkman": true, // SDK manager
".nvm": true, // Node version manager ".nvm": true, // Node version manager
// macOS specific // macOS specific
"Application Scripts": true, // macOS sandboxed app scripts (can have many subdirs) "Application Scripts": true, // macOS sandboxed app scripts (can have many subdirs)
"Saved Application State": true, // App state snapshots "Saved Application State": true, // App state snapshots
// iCloud // iCloud
@@ -444,7 +444,7 @@ func createOverviewEntries() []dirEntry {
dirEntry{name: "System Library", path: "/Library", isDir: true, size: -1}, dirEntry{name: "System Library", path: "/Library", isDir: true, size: -1},
) )
// Add Volumes if exists // Add Volumes shortcut only when it contains real mounted folders (e.g., external disks)
if hasUsefulVolumeMounts("/Volumes") { if hasUsefulVolumeMounts("/Volumes") {
entries = append(entries, dirEntry{name: "Volumes", path: "/Volumes", isDir: true, size: -1}) entries = append(entries, dirEntry{name: "Volumes", path: "/Volumes", isDir: true, size: -1})
} }
@@ -459,13 +459,19 @@ func hasUsefulVolumeMounts(path string) bool {
} }
for _, entry := range entries { for _, entry := range entries {
if entry.Type()&fs.ModeSymlink != 0 { name := entry.Name()
continue // Skip synthetic system links like "Macintosh HD" // Skip hidden control entries for Spotlight/TimeMachine etc.
if strings.HasPrefix(name, ".") {
continue
} }
info, err := entry.Info()
info, err := os.Lstat(filepath.Join(path, name))
if err != nil { if err != nil {
continue continue
} }
if info.Mode()&fs.ModeSymlink != 0 {
continue // Ignore the synthetic MacintoshHD link
}
if info.IsDir() { if info.IsDir() {
return true return true
} }
@@ -1781,7 +1787,7 @@ func truncateMiddle(s string, maxWidth int) string {
headIdx := 0 headIdx := 0
for i, r := range runes { for i, r := range runes {
w := runeWidth(r) w := runeWidth(r)
if headWidth + w > targetHeadWidth { if headWidth+w > targetHeadWidth {
break break
} }
headWidth += w headWidth += w
@@ -1793,7 +1799,7 @@ func truncateMiddle(s string, maxWidth int) string {
tailIdx := len(runes) tailIdx := len(runes)
for i := len(runes) - 1; i >= 0; i-- { for i := len(runes) - 1; i >= 0; i-- {
w := runeWidth(runes[i]) w := runeWidth(runes[i])
if tailWidth + w > targetTailWidth { if tailWidth+w > targetTailWidth {
break break
} }
tailWidth += w tailWidth += w

2
mole
View File

@@ -22,7 +22,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/lib/common.sh" source "$SCRIPT_DIR/lib/common.sh"
# Version info # Version info
VERSION="1.9.11" VERSION="1.9.12"
MOLE_TAGLINE="can dig deep to clean your Mac." MOLE_TAGLINE="can dig deep to clean your Mac."
# Get latest version from remote repository # Get latest version from remote repository