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

Merge branch 'main' of github.com:tw93/Mole

This commit is contained in:
Tw93
2025-12-13 13:39:23 +08:00
3 changed files with 23 additions and 23 deletions

View File

@@ -315,7 +315,7 @@ clean_developer_tools() {
safe_clean "$lock_dir"/* "Homebrew lock files" safe_clean "$lock_dir"/* "Homebrew lock files"
elif [[ -d "$lock_dir" ]]; then elif [[ -d "$lock_dir" ]]; then
# Directory exists but not writable. Check if empty to avoid noise. # Directory exists but not writable. Check if empty to avoid noise.
if [[ -n "$(ls -A "$lock_dir" 2>/dev/null)" ]]; then if [[ -n "$(ls -A "$lock_dir" 2> /dev/null)" ]]; then
# Only try sudo ONCE if we really need to, or just skip to avoid spam # Only try sudo ONCE if we really need to, or just skip to avoid spam
# Decision: Skip strict system/root owned locks to avoid nag. # Decision: Skip strict system/root owned locks to avoid nag.
debug_log "Skipping read-only Homebrew locks in $lock_dir" debug_log "Skipping read-only Homebrew locks in $lock_dir"

View File

@@ -290,7 +290,7 @@ clean_local_snapshots() {
# Format: com.apple.TimeMachine.2023-10-25-120000 # Format: com.apple.TimeMachine.2023-10-25-120000
if [[ "$line" =~ com\.apple\.TimeMachine\.([0-9]{4})-([0-9]{2})-([0-9]{2})-([0-9]{6}) ]]; then if [[ "$line" =~ com\.apple\.TimeMachine\.([0-9]{4})-([0-9]{2})-([0-9]{2})-([0-9]{6}) ]]; then
local date_str="${BASH_REMATCH[1]}-${BASH_REMATCH[2]}-${BASH_REMATCH[3]} ${BASH_REMATCH[4]:0:2}:${BASH_REMATCH[4]:2:2}:${BASH_REMATCH[4]:4:2}" local date_str="${BASH_REMATCH[1]}-${BASH_REMATCH[2]}-${BASH_REMATCH[3]} ${BASH_REMATCH[4]:0:2}:${BASH_REMATCH[4]:2:2}:${BASH_REMATCH[4]:4:2}"
local snap_ts=$(date -j -f "%Y-%m-%d %H:%M:%S" "$date_str" "+%s" 2>/dev/null || echo "0") local snap_ts=$(date -j -f "%Y-%m-%d %H:%M:%S" "$date_str" "+%s" 2> /dev/null || echo "0")
# Skip if parsing failed # Skip if parsing failed
[[ "$snap_ts" == "0" ]] && continue [[ "$snap_ts" == "0" ]] && continue

View File

@@ -126,7 +126,7 @@ clean_sandboxed_app_caches() {
# Check if dir exists and has content # Check if dir exists and has content
if [[ -d "$cache_dir" ]]; then if [[ -d "$cache_dir" ]]; then
# Fast check if empty (avoid expensive size calc on empty dirs) # Fast check if empty (avoid expensive size calc on empty dirs)
if [[ -n "$(ls -A "$cache_dir" 2>/dev/null)" ]]; then if [[ -n "$(ls -A "$cache_dir" 2> /dev/null)" ]]; then
# Get size # Get size
local size=$(get_path_size_kb "$cache_dir") local size=$(get_path_size_kb "$cache_dir")
((total_size += size)) ((total_size += size))
@@ -137,7 +137,7 @@ clean_sandboxed_app_caches() {
# Clean contents safely # Clean contents safely
# We know this is a user cache path, so rm -rf is acceptable here # We know this is a user cache path, so rm -rf is acceptable here
# provided we keep the Cache directory itself # provided we keep the Cache directory itself
rm -rf "$cache_dir"/* 2>/dev/null || true rm -rf "$cache_dir"/* 2> /dev/null || true
fi fi
fi fi
fi fi
@@ -257,14 +257,14 @@ clean_application_support_logs() {
for candidate in "${start_candidates[@]}"; do for candidate in "${start_candidates[@]}"; do
if [[ -d "$candidate" ]]; then if [[ -d "$candidate" ]]; then
if [[ -n "$(ls -A "$candidate" 2>/dev/null)" ]]; then if [[ -n "$(ls -A "$candidate" 2> /dev/null)" ]]; then
local size=$(get_path_size_kb "$candidate") local size=$(get_path_size_kb "$candidate")
((total_size += size)) ((total_size += size))
((cleaned_count++)) ((cleaned_count++))
found_any=true found_any=true
if [[ "$DRY_RUN" != "true" ]]; then if [[ "$DRY_RUN" != "true" ]]; then
safe_remove "$candidate"/* true >/dev/null 2>&1 || true safe_remove "$candidate"/* true > /dev/null 2>&1 || true
fi fi
fi fi
fi fi
@@ -282,14 +282,14 @@ clean_application_support_logs() {
for candidate in "${gc_candidates[@]}"; do for candidate in "${gc_candidates[@]}"; do
if [[ -d "$candidate" ]]; then if [[ -d "$candidate" ]]; then
if [[ -n "$(ls -A "$candidate" 2>/dev/null)" ]]; then if [[ -n "$(ls -A "$candidate" 2> /dev/null)" ]]; then
local size=$(get_path_size_kb "$candidate") local size=$(get_path_size_kb "$candidate")
((total_size += size)) ((total_size += size))
((cleaned_count++)) ((cleaned_count++))
found_any=true found_any=true
if [[ "$DRY_RUN" != "true" ]]; then if [[ "$DRY_RUN" != "true" ]]; then
safe_remove "$candidate"/* true >/dev/null 2>&1 || true safe_remove "$candidate"/* true > /dev/null 2>&1 || true
fi fi
fi fi
fi fi