From ae3889eb3453c628f32ef015b415a939d1845c2e Mon Sep 17 00:00:00 2001 From: Tw93 Date: Mon, 29 Dec 2025 15:34:35 +0800 Subject: [PATCH] Simplify the content deleted by the system --- lib/clean/system.sh | 24 ------------------------ lib/clean/user.sh | 4 ---- lib/core/base.sh | 6 ++++++ 3 files changed, 6 insertions(+), 28 deletions(-) diff --git a/lib/clean/system.sh b/lib/clean/system.sh index 4d90dfc..02802b8 100644 --- a/lib/clean/system.sh +++ b/lib/clean/system.sh @@ -106,30 +106,6 @@ clean_deep_system() { safe_sudo_find_delete "/private/var/db/diagnostics/Special" "*.tracev3" "30" "f" && diag_logs_cleaned=1 || true stop_section_spinner [[ $diag_logs_cleaned -eq 1 ]] && log_success "System diagnostic trace logs" - # Clean core symbolication cache (can be 3-5GB, mostly for crash report debugging) - # Will regenerate when needed for crash analysis - # Use faster du with timeout instead of get_path_size_kb to avoid hanging - debug_log "Checking core symbolication cache..." - if [[ -d "/System/Library/Caches/com.apple.coresymbolicationd/data" ]]; then - debug_log "Symbolication cache directory found, checking size..." - # Quick size check with timeout (max 5 seconds) - local symbolication_size_mb="" - symbolication_size_mb=$(run_with_timeout 5 du -sm "/System/Library/Caches/com.apple.coresymbolicationd/data" 2> /dev/null | awk '{print $1}') - # Validate that we got a valid size (non-empty and numeric) - if [[ -n "$symbolication_size_mb" && "$symbolication_size_mb" =~ ^[0-9]+$ ]]; then - debug_log "Symbolication cache size: ${symbolication_size_mb}MB" - # Only clean if larger than 1GB (1024MB) - if [[ $symbolication_size_mb -gt 1024 ]]; then - debug_log "Cleaning symbolication cache (size > 1GB)..." - if safe_sudo_remove "/System/Library/Caches/com.apple.coresymbolicationd/data"; then - log_success "Core symbolication cache (${symbolication_size_mb}MB)" - fi - fi - else - debug_log "Failed to get symbolication cache size, skipping cleanup" - fi - fi - debug_log "Core symbolication cache section completed" } # Clean incomplete Time Machine backups clean_time_machine_failed_backups() { diff --git a/lib/clean/user.sh b/lib/clean/user.sh index 3646d74..7a68bfb 100644 --- a/lib/clean/user.sh +++ b/lib/clean/user.sh @@ -96,9 +96,6 @@ clean_macos_system_caches() { # Clean saved application states with protection for System Settings # Note: safe_clean already calls should_protect_path for each file safe_clean ~/Library/Saved\ Application\ State/* "Saved application states" || true - # REMOVED: Spotlight cache cleanup can cause system UI issues - # Spotlight indexes should be managed by macOS automatically - # safe_clean ~/Library/Caches/com.apple.spotlight "Spotlight cache" safe_clean ~/Library/Caches/com.apple.photoanalysisd "Photo analysis cache" || true safe_clean ~/Library/Caches/com.apple.akd "Apple ID cache" || true safe_clean ~/Library/Caches/com.apple.WebKit.Networking/* "WebKit network cache" || true @@ -107,7 +104,6 @@ clean_macos_system_caches() { safe_clean ~/Library/Caches/com.apple.QuickLook.thumbnailcache "QuickLook thumbnails" || true safe_clean ~/Library/Caches/Quick\ Look/* "QuickLook cache" || true safe_clean ~/Library/Caches/com.apple.iconservices* "Icon services cache" || true - safe_clean ~/Library/Caches/CloudKit/* "CloudKit cache" || true # Clean incomplete downloads safe_clean ~/Downloads/*.download "Safari incomplete downloads" || true safe_clean ~/Downloads/*.crdownload "Chrome incomplete downloads" || true diff --git a/lib/core/base.sh b/lib/core/base.sh index 50aeae9..abe2d9f 100644 --- a/lib/core/base.sh +++ b/lib/core/base.sh @@ -86,6 +86,12 @@ declare -a DEFAULT_WHITELIST_PATTERNS=( "$HOME/Library/Caches/com.jetbrains.toolbox*" "$HOME/Library/Caches/com.apple.finder" "$HOME/Library/Mobile Documents*" + # System-critical caches that affect macOS functionality and stability + # CRITICAL: Removing these will cause system search and UI issues + "$HOME/Library/Caches/com.apple.FontRegistry*" + "$HOME/Library/Caches/com.apple.spotlight*" + "$HOME/Library/Caches/com.apple.Spotlight*" + "$HOME/Library/Caches/CloudKit*" "$FINDER_METADATA_SENTINEL" )