Skip to content

Commit 80d4565

Browse files
committed
Mailbox cache and whitelist
1 parent db3b033 commit 80d4565

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

bin/clean.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,7 @@ perform_cleanup() {
540540
safe_clean ~/Library/Caches/com.apple.photoanalysisd "Photo analysis cache"
541541
safe_clean ~/Library/Caches/com.apple.akd "Apple ID cache"
542542
safe_clean ~/Library/Caches/com.apple.Safari/Webpage\ Previews/* "Safari webpage previews"
543-
safe_clean ~/Library/Mail/V*/MailData/Envelope\ Index* "Mail envelope index"
544-
safe_clean ~/Library/Mail/V*/MailData/BackupTOC.plist "Mail backup index"
543+
# Mail envelope index and backup index are intentionally not cleaned (issue #32)
545544
safe_clean ~/Library/Application\ Support/CloudDocs/session/db/* "iCloud session cache"
546545
end_section
547546

@@ -1116,6 +1115,7 @@ perform_cleanup() {
11161115
# Note: Disabled by default - container names may not match Bundle IDs
11171116
MOLE_SPINNER_PREFIX=" " start_inline_spinner "Scanning orphaned containers..."
11181117
local containers_found=0
1118+
local containers_size_kb=0
11191119
if ls ~/Library/Containers/com.* > /dev/null 2>&1; then
11201120
# Count potential orphaned containers but don't delete them
11211121
for container_dir in ~/Library/Containers/com.* ~/Library/Containers/org.* ~/Library/Containers/net.* ~/Library/Containers/io.*; do
@@ -1124,15 +1124,20 @@ perform_cleanup() {
11241124
if is_orphaned "$bundle_id" "$container_dir"; then
11251125
local size_kb=$(du -sk "$container_dir" 2> /dev/null | awk '{print $1}' || echo "0")
11261126
if [[ "$size_kb" -gt 0 ]]; then
1127-
# DISABLED: safe_clean "$container_dir" "Orphaned container: $bundle_id"
1127+
# DISABLED: Not cleaned due to potential Bundle ID mismatch risk
11281128
((containers_found++))
1129-
((total_orphaned_kb += size_kb))
1129+
((containers_size_kb += size_kb))
11301130
fi
11311131
fi
11321132
done
11331133
fi
11341134
stop_inline_spinner
1135-
echo -e " ${GREEN}${ICON_SUCCESS}${NC} Skipped $containers_found potential orphaned containers"
1135+
if [[ $containers_found -gt 0 ]]; then
1136+
local containers_mb=$(echo "$containers_size_kb" | awk '{printf "%.1f", $1/1024}')
1137+
echo -e " ${GREEN}${ICON_SUCCESS}${NC} Skipped $containers_found potential orphaned containers (~${containers_mb}MB)"
1138+
else
1139+
echo -e " ${GREEN}${ICON_SUCCESS}${NC} No potential orphaned containers found"
1140+
fi
11361141

11371142
# Clean orphaned WebKit data
11381143
MOLE_SPINNER_PREFIX=" " start_inline_spinner "Scanning orphaned WebKit data..."
@@ -1194,8 +1199,8 @@ perform_cleanup() {
11941199
stop_inline_spinner
11951200
echo -e " ${GREEN}${ICON_SUCCESS}${NC} Found $cookies_found orphaned cookie files"
11961201

1197-
# Calculate total
1198-
orphaned_count=$((cache_found + logs_found + states_found + containers_found + webkit_found + http_found + cookies_found))
1202+
# Calculate total (exclude containers since they were not cleaned)
1203+
orphaned_count=$((cache_found + logs_found + states_found + webkit_found + http_found + cookies_found))
11991204

12001205
if [[ $orphaned_count -gt 0 ]]; then
12011206
local orphaned_mb=$(echo "$total_orphaned_kb" | awk '{printf "%.1f", $1/1024}')

lib/whitelist_manager.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ EOF
6060
get_all_cache_items() {
6161
# Format: "display_name|pattern|category"
6262
cat << 'EOF'
63+
Apple Mail cache|$HOME/Library/Caches/com.apple.mail/*|system_cache
6364
Gradle build cache (Android Studio, Gradle projects)|$HOME/.gradle/caches/*|ide_cache
6465
Gradle daemon processes cache|$HOME/.gradle/daemon/*|ide_cache
6566
Xcode DerivedData (build outputs, indexes)|$HOME/Library/Developer/Xcode/DerivedData/*|ide_cache
@@ -159,10 +160,9 @@ is_whitelisted() {
159160

160161
for existing in "${CURRENT_WHITELIST_PATTERNS[@]}"; do
161162
local existing_expanded="${existing/#\~/$HOME}"
162-
if [[ "$check_pattern" == "$existing_expanded" ]]; then
163-
return 0
164-
fi
165-
if [[ "$check_pattern" == "$existing_expanded" ]]; then
163+
# Support both exact match and glob pattern match
164+
# shellcheck disable=SC2053
165+
if [[ "$check_pattern" == "$existing_expanded" ]] || [[ $check_pattern == $existing_expanded ]]; then
166166
return 0
167167
fi
168168
done

0 commit comments

Comments
 (0)