1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-08 11:29:21 +00:00

feat: add system maintenance cleanup module

- Add broken preferences detection using plutil -lint validation
- Add broken login items cleanup (LaunchAgents pointing to missing files)
- Add universal binary slimming (opt-in via MOLE_SLIM_BINARIES=true)
- Protect Spotify cache if >500MB (likely contains offline music)
- Warn when browsers are running before cache cleanup
- All cleanup stats properly counted in final summary
This commit is contained in:
Yuze Pan
2025-11-30 10:30:22 +08:00
parent 1a6f1cf393
commit b79797faf8
4 changed files with 355 additions and 1 deletions

18
lib/clean_user_apps.sh Normal file → Executable file
View File

@@ -92,8 +92,24 @@ clean_productivity_apps() {
}
# Clean music and media players
# Note: Spotify cache is protected by default (may contain offline music)
# Users can override via whitelist settings
clean_media_players() {
safe_clean ~/Library/Caches/com.spotify.client/* "Spotify cache"
# Spotify cache protection: skip if has offline music (>500MB cache)
local spotify_cache="$HOME/Library/Caches/com.spotify.client"
if [[ -d "$spotify_cache" ]]; then
local cache_size_kb
cache_size_kb=$(du -sk "$spotify_cache" 2> /dev/null | awk '{print $1}' || echo "0")
# Only clean if cache is small (<500MB, unlikely to have offline music)
if [[ $cache_size_kb -lt 512000 ]]; then
safe_clean ~/Library/Caches/com.spotify.client/* "Spotify cache"
else
local cache_human
cache_human=$(bytes_to_human "$((cache_size_kb * 1024))")
echo -e " ${YELLOW}${ICON_WARNING}${NC} Spotify cache protected ($cache_human, may contain offline music)"
note_activity
fi
fi
safe_clean ~/Library/Caches/com.apple.Music "Apple Music cache"
safe_clean ~/Library/Caches/com.apple.podcasts "Apple Podcasts cache"
safe_clean ~/Library/Caches/com.apple.TV/* "Apple TV cache"