From 3906c020fe79a0ca80f53b11361c71b6e5937801 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Sun, 4 Jan 2026 17:41:14 +0800 Subject: [PATCH] fix: improve cleanup by exiting alt screen and refine whitelisting for directory paths and R renv cache. --- bin/installer.sh | 4 ++++ lib/core/app_protection.sh | 11 +++++++++++ lib/core/base.sh | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/bin/installer.sh b/bin/installer.sh index c8596d0..6c39337 100755 --- a/bin/installer.sh +++ b/bin/installer.sh @@ -18,6 +18,10 @@ source "$SCRIPT_DIR/../lib/ui/menu_paginated.sh" cleanup() { + if [[ "${IN_ALT_SCREEN:-0}" == "1" ]]; then + leave_alt_screen + IN_ALT_SCREEN=0 + fi show_cursor cleanup_temp_files } diff --git a/lib/core/app_protection.sh b/lib/core/app_protection.sh index 0957e57..849a261 100755 --- a/lib/core/app_protection.sh +++ b/lib/core/app_protection.sh @@ -598,6 +598,12 @@ is_path_whitelisted() { for pattern in "${WHITELIST_PATTERNS[@]}"; do # Pattern is already expanded/normalized in bin/clean.sh local check_pattern="${pattern%/}" + local has_glob="false" + case "$check_pattern" in + *\**|*\?*|*\[*) + has_glob="true" + ;; + esac # Check for exact match or glob pattern match # shellcheck disable=SC2053 @@ -612,6 +618,11 @@ is_path_whitelisted() { if [[ "$check_pattern" == "$normalized_target"/* ]]; then return 0 fi + + # Check if target is a child of a whitelisted directory path + if [[ "$has_glob" == "false" && "$normalized_target" == "$check_pattern"/* ]]; then + return 0 + fi done return 1 diff --git a/lib/core/base.sh b/lib/core/base.sh index 28940c6..ab39a66 100644 --- a/lib/core/base.sh +++ b/lib/core/base.sh @@ -66,7 +66,7 @@ declare -a DEFAULT_WHITELIST_PATTERNS=( "$HOME/.ollama/models/*" "$HOME/Library/Caches/com.nssurge.surge-mac/*" "$HOME/Library/Application Support/com.nssurge.surge-mac/*" - "$HOME/Library/Caches/org.R-project.R/R/renv" + "$HOME/Library/Caches/org.R-project.R/R/renv/*" "$HOME/Library/Caches/pypoetry/virtualenvs*" "$HOME/Library/Caches/JetBrains*" "$HOME/Library/Caches/com.jetbrains.toolbox*"