1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 17:24:45 +00:00

refactor: centralize whitelist path checking with a new is_path_whitelisted helper function

This commit is contained in:
Tw93
2025-12-28 09:21:04 +08:00
parent 2dd56608e7
commit c8e33931c2
3 changed files with 34 additions and 47 deletions

View File

@@ -222,16 +222,9 @@ safe_clean() {
[[ "$skip" == "true" ]] && continue
# Check user-defined whitelist
if [[ ${#WHITELIST_PATTERNS[@]} -gt 0 ]]; then
for w in "${WHITELIST_PATTERNS[@]}"; do
# Match both exact path and glob pattern
# shellcheck disable=SC2053
if [[ "$path" == "$w" ]] || [[ $path == $w ]]; then
skip=true
((skipped_count++))
break
fi
done
if is_path_whitelisted "$path"; then
skip=true
((skipped_count++))
fi
[[ "$skip" == "true" ]] && continue
[[ -e "$path" ]] && existing_paths+=("$path")