mirror of
https://github.com/tw93/Mole.git
synced 2026-02-12 22:10:14 +00:00
1.9.9
This commit is contained in:
43
bin/clean.sh
43
bin/clean.sh
@@ -15,6 +15,7 @@ source "$SCRIPT_DIR/../lib/common.sh"
|
|||||||
# Configuration
|
# Configuration
|
||||||
SYSTEM_CLEAN=false
|
SYSTEM_CLEAN=false
|
||||||
DRY_RUN=false
|
DRY_RUN=false
|
||||||
|
PROTECT_FINDER_METADATA=false
|
||||||
IS_M_SERIES=$([[ "$(uname -m)" == "arm64" ]] && echo "true" || echo "false")
|
IS_M_SERIES=$([[ "$(uname -m)" == "arm64" ]] && echo "true" || echo "false")
|
||||||
|
|
||||||
# Constants
|
# Constants
|
||||||
@@ -28,12 +29,16 @@ readonly PROTECTED_SW_DOMAINS=(
|
|||||||
"photopea.com"
|
"photopea.com"
|
||||||
"pixlr.com"
|
"pixlr.com"
|
||||||
)
|
)
|
||||||
|
readonly FINDER_METADATA_SENTINEL="FINDER_METADATA"
|
||||||
# Default whitelist patterns (preselected, user can disable)
|
# Default whitelist patterns (preselected, user can disable)
|
||||||
declare -a DEFAULT_WHITELIST_PATTERNS=(
|
declare -a DEFAULT_WHITELIST_PATTERNS=(
|
||||||
"$HOME/Library/Caches/ms-playwright*"
|
"$HOME/Library/Caches/ms-playwright*"
|
||||||
"$HOME/.cache/huggingface*"
|
"$HOME/.cache/huggingface*"
|
||||||
"$HOME/.m2/repository/*"
|
"$HOME/.m2/repository/*"
|
||||||
"$HOME/.ollama/models/*"
|
"$HOME/.ollama/models/*"
|
||||||
|
"$HOME/Library/Caches/com.nssurge.surge-mac/*"
|
||||||
|
"$HOME/Library/Application Support/com.nssurge.surge-mac/*"
|
||||||
|
"$FINDER_METADATA_SENTINEL"
|
||||||
)
|
)
|
||||||
declare -a WHITELIST_PATTERNS=()
|
declare -a WHITELIST_PATTERNS=()
|
||||||
WHITELIST_WARNINGS=()
|
WHITELIST_WARNINGS=()
|
||||||
@@ -87,6 +92,15 @@ if [[ -f "$HOME/.config/mole/whitelist" ]]; then
|
|||||||
else
|
else
|
||||||
WHITELIST_PATTERNS=("${DEFAULT_WHITELIST_PATTERNS[@]}")
|
WHITELIST_PATTERNS=("${DEFAULT_WHITELIST_PATTERNS[@]}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ ${#WHITELIST_PATTERNS[@]} -gt 0 ]]; then
|
||||||
|
for entry in "${WHITELIST_PATTERNS[@]}"; do
|
||||||
|
if [[ "$entry" == "$FINDER_METADATA_SENTINEL" ]]; then
|
||||||
|
PROTECT_FINDER_METADATA=true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
total_items=0
|
total_items=0
|
||||||
|
|
||||||
# Tracking variables
|
# Tracking variables
|
||||||
@@ -691,20 +705,26 @@ perform_cleanup() {
|
|||||||
end_section
|
end_section
|
||||||
|
|
||||||
start_section "Finder metadata"
|
start_section "Finder metadata"
|
||||||
clean_ds_store_tree "$HOME" "Home directory (.DS_Store)"
|
if [[ "$PROTECT_FINDER_METADATA" == "true" ]]; then
|
||||||
|
note_activity
|
||||||
|
echo -e " ${GRAY}○${NC} Finder metadata protected by whitelist (Finder view settings preserved)."
|
||||||
|
echo -e " ${GRAY}○${NC} Use ${GRAY}mo clean --whitelist${NC} to allow cleaning .DS_Store files."
|
||||||
|
else
|
||||||
|
clean_ds_store_tree "$HOME" "Home directory (.DS_Store)"
|
||||||
|
|
||||||
if [[ -d "/Volumes" ]]; then
|
if [[ -d "/Volumes" ]]; then
|
||||||
for volume in /Volumes/*; do
|
for volume in /Volumes/*; do
|
||||||
[[ -d "$volume" && -w "$volume" ]] || continue
|
[[ -d "$volume" && -w "$volume" ]] || continue
|
||||||
|
|
||||||
local fs_type=""
|
local fs_type=""
|
||||||
fs_type=$(df -T "$volume" 2> /dev/null | tail -1 | awk '{print $2}')
|
fs_type=$(df -T "$volume" 2> /dev/null | tail -1 | awk '{print $2}')
|
||||||
case "$fs_type" in
|
case "$fs_type" in
|
||||||
nfs | smbfs | afpfs | cifs | webdav) continue ;;
|
nfs | smbfs | afpfs | cifs | webdav) continue ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
clean_ds_store_tree "$volume" "$(basename "$volume") volume (.DS_Store)"
|
clean_ds_store_tree "$volume" "$(basename "$volume") volume (.DS_Store)"
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
end_section
|
end_section
|
||||||
|
|
||||||
@@ -733,6 +753,7 @@ perform_cleanup() {
|
|||||||
safe_clean ~/Library/Containers/com.apple.wallpaper.agent/Data/Library/Caches/* "Wallpaper agent cache"
|
safe_clean ~/Library/Containers/com.apple.wallpaper.agent/Data/Library/Caches/* "Wallpaper agent cache"
|
||||||
safe_clean ~/Library/Containers/com.apple.mediaanalysisd/Data/Library/Caches/* "Media analysis cache"
|
safe_clean ~/Library/Containers/com.apple.mediaanalysisd/Data/Library/Caches/* "Media analysis cache"
|
||||||
safe_clean ~/Library/Containers/com.apple.AppStore/Data/Library/Caches/* "App Store cache"
|
safe_clean ~/Library/Containers/com.apple.AppStore/Data/Library/Caches/* "App Store cache"
|
||||||
|
safe_clean ~/Library/Containers/com.apple.configurator.xpc.InternetService/Data/tmp/* "Apple Configurator temp files"
|
||||||
safe_clean ~/Library/Containers/*/Data/Library/Caches/* "Sandboxed app caches"
|
safe_clean ~/Library/Containers/*/Data/Library/Caches/* "Sandboxed app caches"
|
||||||
end_section
|
end_section
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ declare -a DEFAULT_WHITELIST_PATTERNS=(
|
|||||||
"$HOME/.ollama/models/*"
|
"$HOME/.ollama/models/*"
|
||||||
"$HOME/Library/Caches/com.nssurge.surge-mac/*"
|
"$HOME/Library/Caches/com.nssurge.surge-mac/*"
|
||||||
"$HOME/Library/Application Support/com.nssurge.surge-mac/*"
|
"$HOME/Library/Application Support/com.nssurge.surge-mac/*"
|
||||||
|
"FINDER_METADATA"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Save whitelist patterns to config
|
# Save whitelist patterns to config
|
||||||
@@ -30,7 +31,7 @@ save_whitelist_patterns() {
|
|||||||
|
|
||||||
cat > "$WHITELIST_CONFIG" << 'EOF'
|
cat > "$WHITELIST_CONFIG" << 'EOF'
|
||||||
# Mole Whitelist - Protected paths won't be deleted
|
# Mole Whitelist - Protected paths won't be deleted
|
||||||
# Default protections: Playwright browsers, HuggingFace models, Maven repo, Ollama models, Surge Mac
|
# Default protections: Playwright browsers, HuggingFace models, Maven repo, Ollama models, Surge Mac, Finder metadata
|
||||||
# Add one pattern per line to keep items safe.
|
# Add one pattern per line to keep items safe.
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
@@ -127,6 +128,7 @@ Podman container cache|$HOME/.local/share/containers/cache/*|container_cache
|
|||||||
Font cache|$HOME/Library/Caches/com.apple.FontRegistry/*|system_cache
|
Font cache|$HOME/Library/Caches/com.apple.FontRegistry/*|system_cache
|
||||||
Spotlight metadata cache|$HOME/Library/Caches/com.apple.spotlight/*|system_cache
|
Spotlight metadata cache|$HOME/Library/Caches/com.apple.spotlight/*|system_cache
|
||||||
CloudKit cache|$HOME/Library/Caches/CloudKit/*|system_cache
|
CloudKit cache|$HOME/Library/Caches/CloudKit/*|system_cache
|
||||||
|
Finder metadata (.DS_Store)|FINDER_METADATA|system_cache
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
mole
2
mole
@@ -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.8"
|
VERSION="1.9.9"
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user