1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-12 05:18:59 +00:00

Scan a large number of files for optimization

This commit is contained in:
Tw93
2025-12-11 16:41:17 +08:00
parent 0d4bbb54dc
commit 57819950bb
3 changed files with 34 additions and 13 deletions

View File

@@ -323,6 +323,11 @@ safe_clean() {
read -r size count < "$result_file" 2> /dev/null || true
if [[ "$count" -gt 0 && "$size" -gt 0 ]]; then
if [[ "$DRY_RUN" != "true" ]]; then
# Update spinner to show cleaning progress
if [[ -t 1 ]] && ((idx % 5 == 0)); then
stop_inline_spinner
MOLE_SPINNER_PREFIX=" " start_inline_spinner "Cleaning items ($idx/$total_paths)..."
fi
# Handle symbolic links separately (only remove the link, not the target)
if [[ -L "$path" ]]; then
rm "$path" 2> /dev/null || true
@@ -344,6 +349,7 @@ safe_clean() {
local total_paths=${#existing_paths[@]}
if [[ -t 1 ]]; then MOLE_SPINNER_PREFIX=" " start_inline_spinner "Scanning $total_paths items..."; fi
local idx=0
for path in "${existing_paths[@]}"; do
local size_bytes
size_bytes=$(get_path_size_kb "$path")
@@ -351,6 +357,11 @@ safe_clean() {
# Optimization: Skip expensive file counting
if [[ "$size_bytes" -gt 0 ]]; then
if [[ "$DRY_RUN" != "true" ]]; then
# Update spinner to show cleaning progress for slow operations
if [[ -t 1 ]]; then
stop_inline_spinner
MOLE_SPINNER_PREFIX=" " start_inline_spinner "Cleaning $description..."
fi
# Handle symbolic links separately (only remove the link, not the target)
if [[ -L "$path" ]]; then
rm "$path" 2> /dev/null || true
@@ -362,6 +373,7 @@ safe_clean() {
((total_count += 1))
removed_any=1
fi
((idx++))
done
fi