1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-08 14:24:21 +00:00

refactor: Extract Apple Silicon cache cleaning to a shared function and improve optimization summary calculation.

This commit is contained in:
Tw93
2025-12-19 20:35:54 +08:00
parent be43f68cc1
commit 240202dfa9
5 changed files with 8 additions and 12 deletions

View File

@@ -6,10 +6,11 @@ set -euo pipefail
# Helper function to clean tool caches using their built-in commands
# Args: $1 - description, $@ - command to execute
# Env: DRY_RUN
# Note: Try to estimate potential savings (many tool caches don't have a direct path,
# so we just report the action if we can't easily find a path)
clean_tool_cache() {
local description="$1"
shift
if [[ "$DRY_RUN" != "true" ]]; then
if "$@" > /dev/null 2>&1; then
echo -e " ${GREEN}${ICON_SUCCESS}${NC} $description"

View File

@@ -366,11 +366,13 @@ check_ios_device_backups() {
# Clean Apple Silicon specific caches
# Env: IS_M_SERIES
clean_apple_silicon_caches() {
if [[ "$IS_M_SERIES" != "true" ]]; then
if [[ "${IS_M_SERIES:-false}" != "true" ]]; then
return 0
fi
start_section "Apple Silicon updates"
safe_clean /Library/Apple/usr/share/rosetta/rosetta_update_bundle "Rosetta 2 cache"
safe_clean ~/Library/Caches/com.apple.rosetta.update "Rosetta 2 user cache"
safe_clean ~/Library/Caches/com.apple.amp.mediasevicesd "Apple Silicon media service cache"
end_section
}