mirror of
https://github.com/tw93/Mole.git
synced 2026-02-15 14:00:05 +00:00
fix: improve cleanup by exiting alt screen and refine whitelisting for directory paths and R renv cache.
This commit is contained in:
@@ -18,6 +18,10 @@ source "$SCRIPT_DIR/../lib/ui/menu_paginated.sh"
|
|||||||
|
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
|
if [[ "${IN_ALT_SCREEN:-0}" == "1" ]]; then
|
||||||
|
leave_alt_screen
|
||||||
|
IN_ALT_SCREEN=0
|
||||||
|
fi
|
||||||
show_cursor
|
show_cursor
|
||||||
cleanup_temp_files
|
cleanup_temp_files
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -598,6 +598,12 @@ is_path_whitelisted() {
|
|||||||
for pattern in "${WHITELIST_PATTERNS[@]}"; do
|
for pattern in "${WHITELIST_PATTERNS[@]}"; do
|
||||||
# Pattern is already expanded/normalized in bin/clean.sh
|
# Pattern is already expanded/normalized in bin/clean.sh
|
||||||
local check_pattern="${pattern%/}"
|
local check_pattern="${pattern%/}"
|
||||||
|
local has_glob="false"
|
||||||
|
case "$check_pattern" in
|
||||||
|
*\**|*\?*|*\[*)
|
||||||
|
has_glob="true"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Check for exact match or glob pattern match
|
# Check for exact match or glob pattern match
|
||||||
# shellcheck disable=SC2053
|
# shellcheck disable=SC2053
|
||||||
@@ -612,6 +618,11 @@ is_path_whitelisted() {
|
|||||||
if [[ "$check_pattern" == "$normalized_target"/* ]]; then
|
if [[ "$check_pattern" == "$normalized_target"/* ]]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
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
|
done
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ declare -a DEFAULT_WHITELIST_PATTERNS=(
|
|||||||
"$HOME/.ollama/models/*"
|
"$HOME/.ollama/models/*"
|
||||||
"$HOME/Library/Caches/com.nssurge.surge-mac/*"
|
"$HOME/Library/Caches/com.nssurge.surge-mac/*"
|
||||||
"$HOME/Library/Application Support/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/pypoetry/virtualenvs*"
|
||||||
"$HOME/Library/Caches/JetBrains*"
|
"$HOME/Library/Caches/JetBrains*"
|
||||||
"$HOME/Library/Caches/com.jetbrains.toolbox*"
|
"$HOME/Library/Caches/com.jetbrains.toolbox*"
|
||||||
|
|||||||
Reference in New Issue
Block a user