mirror of
https://github.com/tw93/Mole.git
synced 2026-02-05 05:39:42 +00:00
Clean Spotlight user caches
This commit is contained in:
@@ -214,3 +214,57 @@ clean_project_caches() {
|
||||
stop_inline_spinner
|
||||
fi
|
||||
}
|
||||
|
||||
# Clean Spotlight user caches
|
||||
# Cleans CoreSpotlight index cache and Spotlight saved state
|
||||
# System Spotlight index (/System/Volumes/Data/.Spotlight-V100) is never touched
|
||||
clean_spotlight_caches() {
|
||||
local cleaned_size=0
|
||||
local cleaned_count=0
|
||||
|
||||
# CoreSpotlight user cache (can grow very large, safe to delete)
|
||||
local spotlight_cache="$HOME/Library/Metadata/CoreSpotlight"
|
||||
if [[ -d "$spotlight_cache" ]]; then
|
||||
local size_kb=$(get_path_size_kb "$spotlight_cache")
|
||||
if [[ "$size_kb" -gt 0 ]]; then
|
||||
if [[ "$DRY_RUN" != "true" ]]; then
|
||||
safe_remove "$spotlight_cache" true && {
|
||||
((cleaned_size += size_kb))
|
||||
((cleaned_count++))
|
||||
echo -e " ${GREEN}${ICON_SUCCESS}${NC} Spotlight cache ($(bytes_to_human $((size_kb * 1024))))"
|
||||
note_activity
|
||||
}
|
||||
else
|
||||
((cleaned_size += size_kb))
|
||||
echo -e " ${YELLOW}→${NC} Spotlight cache (would clean $(bytes_to_human $((size_kb * 1024))))"
|
||||
note_activity
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Spotlight saved application state
|
||||
local spotlight_state="$HOME/Library/Saved Application State/com.apple.spotlight.Spotlight.savedState"
|
||||
if [[ -d "$spotlight_state" ]]; then
|
||||
local size_kb=$(get_path_size_kb "$spotlight_state")
|
||||
if [[ "$size_kb" -gt 0 ]]; then
|
||||
if [[ "$DRY_RUN" != "true" ]]; then
|
||||
safe_remove "$spotlight_state" true && {
|
||||
((cleaned_size += size_kb))
|
||||
((cleaned_count++))
|
||||
echo -e " ${GREEN}${ICON_SUCCESS}${NC} Spotlight state ($(bytes_to_human $((size_kb * 1024))))"
|
||||
note_activity
|
||||
}
|
||||
else
|
||||
((cleaned_size += size_kb))
|
||||
echo -e " ${YELLOW}→${NC} Spotlight state (would clean $(bytes_to_human $((size_kb * 1024))))"
|
||||
note_activity
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $cleaned_size -gt 0 ]]; then
|
||||
((files_cleaned += cleaned_count))
|
||||
((total_size_cleaned += cleaned_size))
|
||||
((total_items++))
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -79,6 +79,10 @@ clean_finder_metadata() {
|
||||
clean_macos_system_caches() {
|
||||
safe_clean ~/Library/Saved\ Application\ State/* "Saved application states"
|
||||
safe_clean ~/Library/Caches/com.apple.spotlight "Spotlight cache"
|
||||
|
||||
# Clean Spotlight user caches (CoreSpotlight can grow very large)
|
||||
clean_spotlight_caches
|
||||
|
||||
safe_clean ~/Library/Caches/com.apple.photoanalysisd "Photo analysis cache"
|
||||
safe_clean ~/Library/Caches/com.apple.akd "Apple ID cache"
|
||||
safe_clean ~/Library/Caches/com.apple.Safari/Webpage\ Previews/* "Safari webpage previews"
|
||||
|
||||
Reference in New Issue
Block a user