1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-08 07:59:16 +00:00

feat: improve app cleanup with orphaned LaunchAgent detection

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
This commit is contained in:
tw93
2026-02-04 16:17:36 +08:00
parent 0fb4d32bb6
commit a4e084a4ed
3 changed files with 479 additions and 7 deletions

View File

@@ -970,6 +970,7 @@ perform_cleanup() {
start_section "Uninstalled app data"
clean_orphaned_app_data
clean_orphaned_system_services
clean_orphaned_launch_agents
end_section
# ===== 13. Apple Silicon optimizations =====