1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 16:14:44 +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

@@ -107,30 +107,8 @@ clean_dev_docker() {
if [[ "$docker_running" == "true" ]]; then
clean_tool_cache "Docker build cache" docker builder prune -af
else
if [[ -t 0 ]]; then
echo -ne " ${YELLOW}${ICON_WARNING}${NC} Docker not running. ${GRAY}Enter${NC} retry / ${GRAY}any key${NC} skip: "
local key
IFS= read -r -s -n1 key || key=""
printf "\r\033[2K"
if [[ -z "$key" || "$key" == $'\n' || "$key" == $'\r' ]]; then
start_section_spinner "Retrying Docker connection..."
local retry_success=false
if run_with_timeout 3 docker info > /dev/null 2>&1; then
retry_success=true
fi
stop_section_spinner
if [[ "$retry_success" == "true" ]]; then
clean_tool_cache "Docker build cache" docker builder prune -af
else
echo -e " ${GRAY}${ICON_SUCCESS}${NC} Docker build cache · still not running"
fi
else
echo -e " ${GRAY}${ICON_SUCCESS}${NC} Docker build cache · skipped"
fi
else
echo -e " ${GRAY}${ICON_SUCCESS}${NC} Docker build cache · daemon not running"
fi
note_activity
# Docker not running - silently skip without user interaction
debug_log "Docker daemon not running, skipping Docker cache cleanup"
fi
else
note_activity

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