- Replace ls with find -maxdepth 1 to reduce IO and permission noise
- Keep same behavior: silently skip if directory is empty or inaccessible
Addresses: user.sh (line 484)
- Normalize npm cache paths with pwd -P to handle symlinks and
trailing slashes, preventing duplicate scans of same directory
- Add declare -f check before calling clean_maven_repository for
robustness when dynamic source fails
- Add test for trailing slash handling
Addresses: dev.sh (line 27, 48, 602)
- Save caller's INT/TERM traps before installing local cleanup trap
- Restore original traps after clean_project_artifacts completes
- Add test to verify trap restoration behavior
Fixes P3 issue: project.sh (line 825, 870)
Add clean_group_container_caches() to safely clean Group Containers:
- Skip Apple-owned containers (com.apple.*, group.com.apple.*, systemgroup.com.apple.*)
- For protected apps: only clean Logs directories
- For non-protected apps: clean Logs, tmp, and Caches
- Add symlink checks to prevent path traversal
- Respect whitelist and should_protect_path checks
- Integrate with clean_sandboxed_app_caches flow
Also add symlink checks in process_container_cache() for consistency.
Includes 4 BATS tests covering protected apps, whitelist,
system containers, and empty results handling.
On macOS (BSD find), -maxdepth must be placed before -name to work
correctly. When placed after, it was ignored causing find to scan
the entire home directory indefinitely on large directories.
Fixes#463
- Add guard flag in cleanup_monitor to prevent duplicate execution
- Check for existing trap in project.sh before setting new one
- Prevents crash when user presses Ctrl-C or scan process fails
Use loops instead of duplicated safe_clean calls for npm cache
directories (_cacache, _npx, _logs, _prebuilds). Add comments
explaining these are not removed by npm cache clean --force.
- Clarify .cxx comment to indicate React Native NDK build cache
- Add protection for Xcode global DerivedData in ~/Library/Developer/Xcode/
to prevent accidental deletion of shared build artifacts
Refs: #461
* feat(clean): add interactive Xcode simulator runtime volumes cleanup
Scan CoreSimulator Volumes/Cryptex directories, detect IN_USE/UNUSED
status via mount points, and let users interactively select items to
clean. Also show size info for unavailable simulator cleanup.
* refactor(clean): auto-clean Xcode simulator runtime volumes
Remove interactive selector, now automatically cleans all UNUSED
runtime volumes while skipping IN_USE and protected paths.
- Fix safe_sudo_remove early exit on error (P1)
- Fix menu filter state leakage in paginated menu (P2)
- Fix cleanup of MOLE_MENU_FILTER_NAMES in app selector (P2)
- Correct log_operation signature for memory dumps (P2)
- Apply minor formatting fixes to dev cleanup module
Fixes the issue reported in PR #410 where mo purge fails to find
artifacts when fd returns empty results.
Changes:
- Implement MO_USE_FIND environment variable to force using find
- Improve fd fallback: check if fd output is empty (-s test)
- Add debug logging to show which tool is being used
- If fd returns no results, fallback to find automatically
This fixes the root cause where fd successfully runs (exit 0) but
finds nothing, preventing the find fallback from being triggered.
Fixes the issue reported in PR #410 where `mo purge` fails to find
artifacts when `fd` returns empty results.
Changes:
- Implement MO_USE_FIND environment variable to force using find
- Improve fd fallback: check if fd output is empty (-s test)
- Add debug logging to show which tool is being used
- If fd returns no results, fallback to find automatically
This fixes the root cause where fd successfully runs (exit 0) but
finds nothing, preventing the find fallback from being triggered.
Optimization:
- Skip -name "*" in safe_sudo_find_delete when pattern matches everything
- Reduces unnecessary parameter passing to find command
- Improves performance for operations that scan all files
Rationale:
- find -name "*" is redundant as it matches everything by default
- Removing it reduces command overhead without changing behavior
Performance improvements:
- Merge 3 separate find operations into 1 for /Library/Caches
- Combine *.cache, *.tmp, *.log patterns in single scan
- Reduces filesystem traversal overhead
- Merge 2 find operations into 1 for /private/var/log
- Combine *.log and *.gz patterns
- Optimize diagnostics cleanup with single combined scan
- Merge Special, Persist, and tracev3 patterns
- Reduces redundant directory traversal
- Use find -delete for batch removal of memory exception reports
- More efficient than iterative removal for large file counts
- Add summary logging to operations.log
UI improvements:
- Add granular spinner messages for each cleanup stage
- Separate diagnostic logs and power logs output for clarity
- Add progress feedback during Time Machine status check
Tests:
- Update sudo mock functions to support new combined find patterns
- Verify find -delete usage for memory exception cleanup
- Update assertions to match optimized implementation
New features:
- Add orphaned LaunchAgent/LaunchDaemon detection with 5-layer verification
- Layer 1: Check if program path exists
- Layer 2: Verify AssociatedBundleIdentifiers via mdfind
- Layer 3: Check Application Support directory activity (7 days)
- Layer 4: Fuzzy match app name in /Applications
- Layer 5: Special handling for PrivilegedHelperTools
- Only process user-level ~/Library/LaunchAgents (safer than system-level)
- Unload agent before removal using launchctl
Bug fixes:
- Handle paths with spaces correctly in orphaned_app_data cleanup
- Add nullglob state management to prevent word splitting
- Use IFS=$'\n' for proper array iteration
- Only count successful deletions (check safe_clean return value)
Tests:
- Add 4 new tests for is_launch_item_orphaned edge cases
- Add tests for space handling and deletion count accuracy