1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-06 09:02:58 +00:00

feat: optimize clean operation performance by pre-expanding whitelist patterns, improving size calculation, and adapting parallel processing based on file types, alongside test suite enhancements.

This commit is contained in:
Tw93
2025-12-30 17:13:43 +08:00
parent 41ce597f02
commit 6c1fcd23d7
6 changed files with 207 additions and 86 deletions

View File

@@ -642,14 +642,13 @@ is_path_whitelisted() {
[[ ${#WHITELIST_PATTERNS[@]} -eq 0 ]] && return 1
for pattern in "${WHITELIST_PATTERNS[@]}"; do
# Expand tilde in whitelist pattern for comparison
local expanded_pattern="${pattern/#\~/$HOME}"
expanded_pattern="${expanded_pattern%/}"
# Pattern is already expanded/normalized in bin/clean.sh
local check_pattern="${pattern%/}"
# Check for exact match or glob pattern match
# shellcheck disable=SC2053
if [[ "$normalized_target" == "$expanded_pattern" ]] ||
[[ "$normalized_target" == $expanded_pattern ]]; then
if [[ "$normalized_target" == "$check_pattern" ]] ||
[[ "$normalized_target" == $check_pattern ]]; then
return 0
fi
done