From cec6d7a46239477562b1e59f8e03326763bb7f4f Mon Sep 17 00:00:00 2001 From: Tw93 Date: Sat, 6 Dec 2025 20:09:32 +0800 Subject: [PATCH] Do not clean up the system panel cache --- bin/clean.sh | 11 +++++++++++ lib/core/common.sh | 9 +++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/bin/clean.sh b/bin/clean.sh index 1840b79..98559e7 100755 --- a/bin/clean.sh +++ b/bin/clean.sh @@ -230,6 +230,17 @@ safe_clean() { ;; esac + # Protect system app containers from accidental cleanup + # Extract bundle ID from ~/Library/Containers//... paths + if [[ "$path" == */Library/Containers/* ]] && [[ "$path" =~ /Library/Containers/([^/]+)/ ]]; then + local container_bundle_id="${BASH_REMATCH[1]}" + if should_protect_data "$container_bundle_id"; then + debug_log "Protecting system container: $container_bundle_id" + skip=true + ((skipped_count++)) + fi + fi + [[ "$skip" == "true" ]] && continue # Check user-defined whitelist diff --git a/lib/core/common.sh b/lib/core/common.sh index 20a8c22..2ea12c6 100755 --- a/lib/core/common.sh +++ b/lib/core/common.sh @@ -1800,10 +1800,11 @@ bundle_matches_pattern() { [[ -z "$pattern" ]] && return 1 - # shellcheck disable=SC2254 # allow glob pattern matching for bundle rules - case "$bundle_id" in - $pattern) return 0 ;; - esac + # Use bash [[ ]] for glob pattern matching (works with variables in bash 3.2+) + # shellcheck disable=SC2053 # allow glob pattern matching + if [[ "$bundle_id" == $pattern ]]; then + return 0 + fi return 1 }