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

Automatic formatting

This commit is contained in:
Tw93
2025-10-12 21:43:37 +08:00
parent cf821cdc4b
commit 62537d8d44
8 changed files with 15 additions and 46 deletions

View File

@@ -21,7 +21,6 @@ readonly CACHE_DIR="${HOME}/.config/mole/cache"
readonly TEMP_PREFIX="/tmp/mole_analyze_$$"
readonly MIN_LARGE_FILE_SIZE="1000000000" # 1GB
readonly MIN_MEDIUM_FILE_SIZE="100000000" # 100MB
readonly MIN_SMALL_FILE_SIZE="10000000" # 10MB
# Emoji badges for list displays only
readonly BADGE_DIR="🍞"
@@ -32,17 +31,12 @@ readonly BADGE_LOG="🍹"
readonly BADGE_APP="🐣"
# Global state
declare -a SCAN_RESULTS=()
declare -a DIR_RESULTS=()
declare -a LARGE_FILES=()
declare SCAN_PID=""
declare TOTAL_SIZE=0
declare CURRENT_PATH="$HOME"
declare CURRENT_DEPTH=1
# UI State
declare CURSOR_POS=0
declare SORT_MODE="size" # size, name, time
declare VIEW_MODE="overview" # overview, detail, files
# Cleanup on exit
@@ -281,8 +275,6 @@ perform_scan() {
"Calculating sizes"
"Finishing up"
)
local msg_idx=0
while kill -0 "$SCAN_PID" 2> /dev/null; do
# Show different messages based on elapsed time
local current_msg=""
@@ -1297,8 +1289,6 @@ display_interactive_menu() {
# Analyze file types
display_file_types() {
local temp_types="$TEMP_PREFIX.types"
log_header "File Types Analysis"
echo ""
@@ -1617,7 +1607,7 @@ show_volumes_overview() {
output+=$'\n'
local idx=0
while IFS='|' read -r priority path display_name; do
while IFS='|' read -r _ path display_name; do
# Build line (simple display without size)
local line=""
if [[ $idx -eq $cursor ]]; then
@@ -1650,7 +1640,7 @@ show_volumes_overview() {
# Get selected path and enter it
local selected_path=""
idx=0
while IFS='|' read -r priority path display_name; do
while IFS='|' read -r _ path _; do
if [[ $idx -eq $cursor ]]; then
selected_path="$path"
break
@@ -1697,7 +1687,6 @@ show_volumes_overview() {
# Interactive drill-down mode
interactive_drill_down() {
local start_path="$1"
local initial_items="${2:-}" # Pre-scanned items for first level
local current_path="$start_path"
local path_stack=()
local cursor=0
@@ -1709,7 +1698,6 @@ interactive_drill_down() {
# Cache variables to avoid recalculation
local -a items=()
local has_calculating=false
local total_items=0
# Directory cache: store scan results for each visited directory
@@ -1783,7 +1771,6 @@ interactive_drill_down() {
total_items=${#items[@]}
# No more calculating state
has_calculating=false
need_scan=false
wait_for_calc=false

View File

@@ -21,8 +21,6 @@ IS_M_SERIES=$([ "$(uname -m)" = "arm64" ] && echo "true" || echo "false")
readonly MAX_PARALLEL_JOBS=15 # Maximum parallel background jobs
readonly TEMP_FILE_AGE_DAYS=7 # Age threshold for temp file cleanup
readonly ORPHAN_AGE_DAYS=60 # Age threshold for orphaned data
readonly SIZE_1GB_KB=1048576 # 1GB in kilobytes
readonly SIZE_1MB_KB=1024 # 1MB in kilobytes
# Default whitelist patterns (preselected, user can disable)
declare -a DEFAULT_WHITELIST_PATTERNS=(
"$HOME/Library/Caches/ms-playwright*"
@@ -78,7 +76,6 @@ total_items=0
# Tracking variables
TRACK_SECTION=0
SECTION_ACTIVITY=0
LAST_CLEAN_RESULT=0
files_cleaned=0
total_size_cleaned=0
whitelist_skipped_count=0
@@ -246,7 +243,6 @@ safe_clean() {
fi
if [[ ${#existing_paths[@]} -eq 0 ]]; then
LAST_CLEAN_RESULT=0
return 0
fi
@@ -349,7 +345,6 @@ safe_clean() {
note_activity
fi
LAST_CLEAN_RESULT=$removed_any
return 0
}
@@ -448,9 +443,6 @@ perform_cleanup() {
echo -e "${BLUE}${ICON_SUCCESS}${NC} Whitelist: 2 core patterns active"
fi
# Get initial space
space_before=$(df / | tail -1 | awk '{print $4}')
# Initialize counters
total_items=0
files_cleaned=0
@@ -1457,9 +1449,6 @@ perform_cleanup() {
end_section
# ===== Final summary =====
space_after=$(df / | tail -1 | awk '{print $4}')
space_freed_kb=$((space_after - space_before))
echo ""
local summary_heading=""