mirror of
https://github.com/tw93/Mole.git
synced 2026-02-11 12:59:16 +00:00
fix silent exit on permission denied during App State Cleanup (#440)
This commit is contained in:
@@ -164,7 +164,7 @@ opt_cache_refresh() {
|
||||
if [[ "$size_kb" =~ ^[0-9]+$ ]]; then
|
||||
total_cache_size=$((total_cache_size + size_kb))
|
||||
fi
|
||||
safe_remove "$target_path" true > /dev/null 2>&1
|
||||
safe_remove "$target_path" true > /dev/null 2>&1 || true
|
||||
fi
|
||||
fi
|
||||
done
|
||||
@@ -195,7 +195,7 @@ opt_saved_state_cleanup() {
|
||||
if should_protect_path "$state_path"; then
|
||||
continue
|
||||
fi
|
||||
safe_remove "$state_path" true > /dev/null 2>&1
|
||||
safe_remove "$state_path" true > /dev/null 2>&1 || true
|
||||
done < <(command find "$state_dir" -type d -name "*.savedState" -mtime "+$MOLE_SAVED_STATE_AGE_DAYS" -print0 2> /dev/null)
|
||||
fi
|
||||
|
||||
|
||||
@@ -500,6 +500,23 @@ EOF
|
||||
[[ "$output" == *"App saved states optimized"* ]]
|
||||
}
|
||||
|
||||
@test "opt_saved_state_cleanup continues on permission denied (silent exit)" {
|
||||
local state_dir="$HOME/Library/Saved Application State"
|
||||
mkdir -p "$state_dir/com.example.old.savedState"
|
||||
touch -t 202301010000 "$state_dir/com.example.old.savedState" 2>/dev/null || true
|
||||
|
||||
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc << 'EOF'
|
||||
set -euo pipefail
|
||||
source "$PROJECT_ROOT/lib/core/common.sh"
|
||||
source "$PROJECT_ROOT/lib/optimize/tasks.sh"
|
||||
safe_remove() { return 1; }
|
||||
opt_saved_state_cleanup
|
||||
EOF
|
||||
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" == *"App saved states optimized"* ]]
|
||||
}
|
||||
|
||||
@test "opt_cache_refresh cleans Quick Look cache" {
|
||||
mkdir -p "$HOME/Library/Caches/com.apple.QuickLook.thumbnailcache"
|
||||
touch "$HOME/Library/Caches/com.apple.QuickLook.thumbnailcache/test.db"
|
||||
|
||||
Reference in New Issue
Block a user