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

refactor: rename total_size_bytes to total_size_kb in clean.sh for clarity

This commit is contained in:
Tw93
2025-12-30 14:55:43 +08:00
parent 3ba406b5e7
commit 1c4b033cf7

View File

@@ -198,7 +198,7 @@ safe_clean() {
fi fi
local removed_any=0 local removed_any=0
local total_size_bytes=0 local total_size_kb=0
local total_count=0 local total_count=0
local skipped_count=0 local skipped_count=0
local removal_failed_count=0 local removal_failed_count=0
@@ -329,7 +329,7 @@ safe_clean() {
fi fi
fi fi
if [[ $removed -eq 1 ]]; then if [[ $removed -eq 1 ]]; then
((total_size_bytes += size)) ((total_size_kb += size))
((total_count += 1)) ((total_count += 1))
removed_any=1 removed_any=1
else else
@@ -344,13 +344,13 @@ safe_clean() {
else else
local idx=0 local idx=0
for path in "${existing_paths[@]}"; do for path in "${existing_paths[@]}"; do
local size_bytes local size_kb
size_bytes=$(get_path_size_kb "$path") size_kb=$(get_path_size_kb "$path")
# Ensure size_bytes is numeric (additional safety layer) # Ensure size_kb is numeric (additional safety layer)
[[ ! "$size_bytes" =~ ^[0-9]+$ ]] && size_bytes=0 [[ ! "$size_kb" =~ ^[0-9]+$ ]] && size_kb=0
# Optimization: Skip expensive file counting # Optimization: Skip expensive file counting
if [[ "$size_bytes" -gt 0 ]]; then if [[ "$size_kb" -gt 0 ]]; then
local removed=1 local removed=1
if [[ "$DRY_RUN" != "true" ]]; then if [[ "$DRY_RUN" != "true" ]]; then
removed=0 removed=0
@@ -364,7 +364,7 @@ safe_clean() {
fi fi
fi fi
if [[ $removed -eq 1 ]]; then if [[ $removed -eq 1 ]]; then
((total_size_bytes += size_bytes)) ((total_size_kb += size_kb))
((total_count += 1)) ((total_count += 1))
removed_any=1 removed_any=1
else else
@@ -390,7 +390,7 @@ safe_clean() {
fi fi
if [[ $removed_any -eq 1 ]]; then if [[ $removed_any -eq 1 ]]; then
local size_human=$(bytes_to_human "$((total_size_bytes * 1024))") local size_human=$(bytes_to_human "$((total_size_kb * 1024))")
local label="$description" local label="$description"
if [[ ${#targets[@]} -gt 1 ]]; then if [[ ${#targets[@]} -gt 1 ]]; then
@@ -461,7 +461,7 @@ safe_clean() {
echo -e " ${GREEN}${ICON_SUCCESS}${NC} $label ${GREEN}($size_human)${NC}" echo -e " ${GREEN}${ICON_SUCCESS}${NC} $label ${GREEN}($size_human)${NC}"
fi fi
((files_cleaned += total_count)) ((files_cleaned += total_count))
((total_size_cleaned += total_size_bytes)) ((total_size_cleaned += total_size_kb))
((total_items++)) ((total_items++))
note_activity note_activity
fi fi