1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-15 23:11:11 +00:00

Optimize the start speed of optimize

This commit is contained in:
Tw93
2025-12-06 20:57:08 +08:00
parent 1b2da97032
commit 03610e34a5
4 changed files with 22 additions and 21 deletions

View File

@@ -121,8 +121,8 @@ show_system_health() {
uptime=${uptime:-0} uptime=${uptime:-0}
# Compact one-line format with icon # Compact one-line format with icon
printf "${ICON_ADMIN} System %.0f/%.0f GB RAM | %.0f/%.0f GB Disk (%.0f%%) | Uptime %.0fd\n" \ printf "${ICON_ADMIN} System %.0f/%.0f GB RAM | %.0f/%.0f GB Disk | Uptime %.0fd\n" \
"$mem_used" "$mem_total" "$disk_used" "$disk_total" "$disk_percent" "$uptime" "$mem_used" "$mem_total" "$disk_used" "$disk_total" "$uptime"
echo "" echo ""
} }

View File

@@ -1248,7 +1248,8 @@ get_path_size_kb() {
return return
} }
local result local result
result=$(command du -sk "$path" 2> /dev/null | awk '{print $1}') # Timeout protection: prevent du from hanging on large directories
result=$(run_with_timeout 5 sh -c "command du -sk \"$path\" 2> /dev/null | awk '{print \$1}'")
echo "${result:-0}" echo "${result:-0}"
} }

View File

@@ -662,7 +662,7 @@ EOF
# Collect all optimization items # Collect all optimization items
local -a items=() local -a items=()
# Always-on items # Always-on items (no size checks - instant)
items+=('system_maintenance|System Maintenance|Rebuild system databases & flush caches|true') items+=('system_maintenance|System Maintenance|Rebuild system databases & flush caches|true')
items+=('maintenance_scripts|Maintenance Scripts|Run daily/weekly/monthly scripts & rotate logs|true') items+=('maintenance_scripts|Maintenance Scripts|Run daily/weekly/monthly scripts & rotate logs|true')
items+=('radio_refresh|Bluetooth & Wi-Fi Refresh|Reset wireless preference caches|true') items+=('radio_refresh|Bluetooth & Wi-Fi Refresh|Reset wireless preference caches|true')
@@ -670,22 +670,22 @@ EOF
items+=('log_cleanup|Diagnostics Cleanup|Purge old diagnostic & crash logs|true') items+=('log_cleanup|Diagnostics Cleanup|Purge old diagnostic & crash logs|true')
items+=('startup_cache|Startup Cache Rebuild|Rebuild kext caches & prelinked kernel|true') items+=('startup_cache|Startup Cache Rebuild|Rebuild kext caches & prelinked kernel|true')
# Conditional items # Skip conditional checks - they require du which is slow
local item # Users will see actual results when optimization runs
item=$(check_cache_refresh || true) # item=$(check_cache_refresh || true)
[[ -n "$item" ]] && items+=("$item") # [[ -n "$item" ]] && items+=("$item")
item=$(check_mail_downloads || true) # item=$(check_mail_downloads || true)
[[ -n "$item" ]] && items+=("$item") # [[ -n "$item" ]] && items+=("$item")
item=$(check_saved_state || true) # item=$(check_saved_state || true)
[[ -n "$item" ]] && items+=("$item") # [[ -n "$item" ]] && items+=("$item")
item=$(check_swap_cleanup || true) # item=$(check_swap_cleanup || true)
[[ -n "$item" ]] && items+=("$item") # [[ -n "$item" ]] && items+=("$item")
item=$(check_local_snapshots || true) # item=$(check_local_snapshots || true)
[[ -n "$item" ]] && items+=("$item") # [[ -n "$item" ]] && items+=("$item")
item=$(check_developer_cleanup || true) # item=$(check_developer_cleanup || true)
[[ -n "$item" ]] && items+=("$item") # [[ -n "$item" ]] && items+=("$item")
item=$(check_broken_configs || true) # item=$(check_broken_configs || true)
[[ -n "$item" ]] && items+=("$item") # [[ -n "$item" ]] && items+=("$item")
# Output items as JSON # Output items as JSON
local first=true local first=true

2
mole
View File

@@ -22,7 +22,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/lib/core/common.sh" source "$SCRIPT_DIR/lib/core/common.sh"
# Version info # Version info
VERSION="1.11.33" VERSION="1.11.34"
MOLE_TAGLINE="can dig deep to clean your Mac." MOLE_TAGLINE="can dig deep to clean your Mac."
# Check if Touch ID is already configured # Check if Touch ID is already configured