mirror of
https://github.com/tw93/Mole.git
synced 2026-02-15 14:00:05 +00:00
chore: auto format code
This commit is contained in:
@@ -293,11 +293,11 @@ func TestCalculateNameWidth(t *testing.T) {
|
|||||||
wantMin int
|
wantMin int
|
||||||
wantMax int
|
wantMax int
|
||||||
}{
|
}{
|
||||||
{80, 19, 60}, // 80 - 61 = 19
|
{80, 19, 60}, // 80 - 61 = 19
|
||||||
{120, 59, 60}, // 120 - 61 = 59
|
{120, 59, 60}, // 120 - 61 = 59
|
||||||
{200, 60, 60}, // Capped at 60
|
{200, 60, 60}, // Capped at 60
|
||||||
{70, 24, 60}, // Below minimum, use 24
|
{70, 24, 60}, // Below minimum, use 24
|
||||||
{50, 24, 60}, // Very small, use minimum
|
{50, 24, 60}, // Very small, use minimum
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ clean_deep_system() {
|
|||||||
debug_log "Symbolication cache directory found, checking size..."
|
debug_log "Symbolication cache directory found, checking size..."
|
||||||
# Quick size check with timeout (max 5 seconds)
|
# Quick size check with timeout (max 5 seconds)
|
||||||
local symbolication_size_mb=""
|
local symbolication_size_mb=""
|
||||||
symbolication_size_mb=$(run_with_timeout 5 du -sm "/System/Library/Caches/com.apple.coresymbolicationd/data" 2>/dev/null | awk '{print $1}')
|
symbolication_size_mb=$(run_with_timeout 5 du -sm "/System/Library/Caches/com.apple.coresymbolicationd/data" 2> /dev/null | awk '{print $1}')
|
||||||
|
|
||||||
# Validate that we got a valid size (non-empty and numeric)
|
# Validate that we got a valid size (non-empty and numeric)
|
||||||
if [[ -n "$symbolication_size_mb" && "$symbolication_size_mb" =~ ^[0-9]+$ ]]; then
|
if [[ -n "$symbolication_size_mb" && "$symbolication_size_mb" =~ ^[0-9]+$ ]]; then
|
||||||
@@ -170,7 +170,7 @@ clean_deep_system() {
|
|||||||
|
|
||||||
# Clean each path if exists
|
# Clean each path if exists
|
||||||
for ali_path in "${ali_paths[@]}"; do
|
for ali_path in "${ali_paths[@]}"; do
|
||||||
if sudo test -e "$ali_path" 2>/dev/null; then
|
if sudo test -e "$ali_path" 2> /dev/null; then
|
||||||
debug_log "Found Aliyun component: $ali_path, removing..."
|
debug_log "Found Aliyun component: $ali_path, removing..."
|
||||||
safe_sudo_remove "$ali_path" && ((ali_cleaned++)) || true
|
safe_sudo_remove "$ali_path" && ((ali_cleaned++)) || true
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -186,12 +186,12 @@ safe_sudo_find_delete() {
|
|||||||
local type_filter="${4:-f}"
|
local type_filter="${4:-f}"
|
||||||
|
|
||||||
# Validate base directory (use sudo for permission-restricted dirs)
|
# Validate base directory (use sudo for permission-restricted dirs)
|
||||||
if ! sudo test -d "$base_dir" 2>/dev/null; then
|
if ! sudo test -d "$base_dir" 2> /dev/null; then
|
||||||
debug_log "Directory does not exist (skipping): $base_dir"
|
debug_log "Directory does not exist (skipping): $base_dir"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if sudo test -L "$base_dir" 2>/dev/null; then
|
if sudo test -L "$base_dir" 2> /dev/null; then
|
||||||
log_error "Refusing to search symlinked directory: $base_dir"
|
log_error "Refusing to search symlinked directory: $base_dir"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ opt_network_optimization() {
|
|||||||
opt_sqlite_vacuum() {
|
opt_sqlite_vacuum() {
|
||||||
local optimized_count=0
|
local optimized_count=0
|
||||||
local total_saved_kb=0
|
local total_saved_kb=0
|
||||||
local min_size_kb=1024 # Only optimize databases larger than 1MB
|
local min_size_kb=1024 # Only optimize databases larger than 1MB
|
||||||
|
|
||||||
# List of safe databases to optimize
|
# List of safe databases to optimize
|
||||||
# Exclude critical system databases like Mail, Messages, Photos
|
# Exclude critical system databases like Mail, Messages, Photos
|
||||||
@@ -228,7 +228,7 @@ opt_sqlite_vacuum() {
|
|||||||
[[ ! -f "$db_path" ]] && continue
|
[[ ! -f "$db_path" ]] && continue
|
||||||
|
|
||||||
# Check if it's a SQLite database
|
# Check if it's a SQLite database
|
||||||
if ! file "$db_path" 2>/dev/null | grep -q "SQLite"; then
|
if ! file "$db_path" 2> /dev/null | grep -q "SQLite"; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -252,7 +252,7 @@ opt_sqlite_vacuum() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Verify database integrity before VACUUM
|
# Verify database integrity before VACUUM
|
||||||
if ! sqlite3 "$db_path" "PRAGMA integrity_check;" 2>/dev/null | grep -q "ok"; then
|
if ! sqlite3 "$db_path" "PRAGMA integrity_check;" 2> /dev/null | grep -q "ok"; then
|
||||||
debug_log "Skipping $db_path - integrity check failed"
|
debug_log "Skipping $db_path - integrity check failed"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@@ -261,9 +261,9 @@ opt_sqlite_vacuum() {
|
|||||||
local size_before=$db_size_kb
|
local size_before=$db_size_kb
|
||||||
|
|
||||||
# Perform VACUUM with error handling
|
# Perform VACUUM with error handling
|
||||||
if sqlite3 "$db_path" "VACUUM;" 2>/dev/null; then
|
if sqlite3 "$db_path" "VACUUM;" 2> /dev/null; then
|
||||||
# Verify database integrity after VACUUM
|
# Verify database integrity after VACUUM
|
||||||
if ! sqlite3 "$db_path" "PRAGMA integrity_check;" 2>/dev/null | grep -q "ok"; then
|
if ! sqlite3 "$db_path" "PRAGMA integrity_check;" 2> /dev/null | grep -q "ok"; then
|
||||||
debug_log "Warning: $db_path integrity check failed after VACUUM"
|
debug_log "Warning: $db_path integrity check failed after VACUUM"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user