mirror of
https://github.com/tw93/Mole.git
synced 2026-03-23 21:35:06 +00:00
fix(clean): align threshold colors with displayed GB units
This commit is contained in:
@@ -79,6 +79,7 @@ readonly MOLE_TM_BACKUP_SAFE_HOURS=48 # TM backup safety window (hours)
|
||||
readonly MOLE_MAX_DS_STORE_FILES=500 # Max .DS_Store files to clean per scan
|
||||
readonly MOLE_MAX_ORPHAN_ITERATIONS=100 # Max iterations for orphaned app data scan
|
||||
readonly MOLE_ONE_GIB_KB=$((1024 * 1024))
|
||||
readonly MOLE_ONE_GB_BYTES=1000000000
|
||||
|
||||
# ============================================================================
|
||||
# Whitelist Configuration
|
||||
@@ -549,12 +550,12 @@ bytes_to_human_kb() {
|
||||
bytes_to_human "$((${1:-0} * 1024))"
|
||||
}
|
||||
|
||||
# Pick a cleanup result color using the shared 1 GiB threshold.
|
||||
# Pick a cleanup result color using the displayed decimal 1 GB threshold.
|
||||
cleanup_result_color_kb() {
|
||||
local size_kb="${1:-0}"
|
||||
[[ "$size_kb" =~ ^[0-9]+$ ]] || size_kb=0
|
||||
|
||||
if ((size_kb >= MOLE_ONE_GIB_KB)); then
|
||||
if ((size_kb * 1024 >= MOLE_ONE_GB_BYTES)); then
|
||||
printf '%s' "$GREEN"
|
||||
else
|
||||
printf '%s' "$YELLOW"
|
||||
|
||||
@@ -44,13 +44,16 @@ setup() {
|
||||
[[ -n "$result" ]]
|
||||
}
|
||||
|
||||
@test "cleanup_result_color_kb switches from yellow to green at 1 GiB" {
|
||||
@test "cleanup_result_color_kb switches from yellow to green at 1 GB" {
|
||||
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<'EOF'
|
||||
set -euo pipefail
|
||||
source "$PROJECT_ROOT/lib/core/common.sh"
|
||||
|
||||
if [[ "$(cleanup_result_color_kb $((MOLE_ONE_GIB_KB - 1)))" == "$YELLOW" ]] &&
|
||||
[[ "$(cleanup_result_color_kb "$MOLE_ONE_GIB_KB")" == "$GREEN" ]]; then
|
||||
below_threshold_kb=$(((MOLE_ONE_GB_BYTES - 1) / 1024))
|
||||
at_threshold_kb=$(((MOLE_ONE_GB_BYTES + 1023) / 1024))
|
||||
|
||||
if [[ "$(cleanup_result_color_kb "$below_threshold_kb")" == "$YELLOW" ]] &&
|
||||
[[ "$(cleanup_result_color_kb "$at_threshold_kb")" == "$GREEN" ]]; then
|
||||
echo "ok"
|
||||
fi
|
||||
EOF
|
||||
|
||||
Reference in New Issue
Block a user