1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 14:26:46 +00:00
Commit Graph

1519 Commits

Author SHA1 Message Date
tw93
8ac71a3937 fix: add clash patterns to data protection checks 2026-01-31 20:05:38 +08:00
tw93
c34d8e71c8 fix: correct minimum purge scan depth from 2 to 1 2026-01-31 20:05:34 +08:00
tw93
0fcf777230 refactor: simplify channel send logic with trySend function 2026-01-31 20:05:21 +08:00
github-actions[bot]
16c1534dc3 chore: update contributors [skip ci] 2026-01-31 09:46:10 +00:00
tw93
81c58b5b89 fix: increase purge max depth from 4 to 6 to find deeply nested artifacts
Fixes #394

Users reported that `mo purge` could not find `node_modules` folders in
deeply nested project structures. The issue was caused by `PURGE_MAX_DEPTH_DEFAULT=4`
being too restrictive for real-world project organizations.

Example failing case:
~/Projects/Company/Division/Team/MyProject/node_modules  (depth 5)
~/Projects/Org/ClientA/Backend/Services/API/node_modules (depth 6)

Changes:
- Increased PURGE_MAX_DEPTH_DEFAULT from 4 to 6
- This covers 95%+ of real-world project structures
- Performance impact: ~15-25% slower scan (acceptable trade-off for correctness)
- All 41 existing tests pass with the new depth limit

Verified:
- Tested with structures at depths 2-6, all artifacts now detected
- No breaking changes to existing functionality
- Users with fd (fast) won't notice performance difference
2026-01-31 17:45:37 +08:00
tw93
aa6f6c503f refactor: add feedback for fallback Trash cleanup
Improve user experience when osascript fails to empty Trash:
- Count successfully cleaned items
- Display cleanup confirmation message
- Only show message if items were actually cleaned
- Call note_activity to record the cleanup

This ensures users get consistent feedback regardless of which
cleanup method is used (osascript vs find fallback).
2026-01-31 17:40:07 +08:00
github-actions[bot]
6e91a82c7c chore: update contributors [skip ci] 2026-01-31 09:38:20 +00:00
tw93
82df7abc35 Merge branch 'main' into dev 2026-01-31 17:37:46 +08:00
dekran
dcac6a3391 fix: handle dotfiles in Trash cleanup (#395)
Replace glob pattern with find command to properly clean dotfiles
in Trash when osascript fallback is used. The old pattern
~/.Trash/* does not match files starting with "." in bash.

This fix ensures that hidden files like .DS_Store, .hidden_file,
etc. are properly removed when cleaning the Trash.
2026-01-31 17:37:22 +08:00
tw93
15bb60c531 perf: fix should_protect_data performance regression with case optimization
Issue #393 reported mo clean hanging on 'Scanning sandboxed apps'
and 'Scanning orphaned app resources'.

Root cause: should_protect_data() was looping through 332 patterns
(28 SYSTEM_CRITICAL_BUNDLES_FAST + 304 DATA_PROTECTED_BUNDLES).
For 662 sandboxed containers, this resulted in 220,000+ pattern matches.

Solution: Replace loops with fast case statement for common prefixes:
- com.apple.* (system apps) - instant return
- com.microsoft.*, com.jetbrains.* (IDEs) - instant return
- Password managers, VPNs, Docker etc. - instant return
- Other apps - instant return (no protection needed)
- Only check detailed list for special wildcards (com.tencent.* etc.)

Performance: Clean command maintains 35s (same as previous optimization)
Functionality: All 9 protection tests pass
2026-01-31 11:54:26 +08:00
tw93
9d2c907c08 perf: optimize app protection with dual-array strategy and lazy loading
- Add SYSTEM_CRITICAL_BUNDLES_FAST (30 items) for clean operations
- Keep SYSTEM_CRITICAL_BUNDLES (60+ items) for uninstall precision
- Implement lazy regex loading - only build when uninstall is triggered
- Use fast wildcard matching for should_protect_data (clean scenario)
- Use detailed regex matching for should_protect_from_uninstall

Performance improvement:
- Clean command: 71s → 35s (51% faster)
- System CPU: 17.3s → 5.9s (66% reduction)
- Now 27% faster than v1.23.2 baseline (48s → 35s)

Fixes performance regression introduced in commit 2865a78 where
SYSTEM_CRITICAL_BUNDLES expanded from 5 wildcards to 60+ explicit entries.
2026-01-31 11:31:51 +08:00
tw93
70089e5a4f Merge remote-tracking branch 'origin/main'
Resolved conflict in lib/core/base.sh:
- Kept local version with conditional check in stop_section_spinner
- This prevents clearing lines when no spinner is running (fixes extra blank lines)
2026-01-31 10:11:14 +08:00
tw93
e12a40f6bf fix: use \033[2K to fully clear spinner lines and prevent text remnants
Fixes text remnants and extra blank lines when spinner messages change.

Issues fixed:
1. Text remnants when switching from longer to shorter messages (e.g., 'Cleaning...ems...')
2. Extra blank lines appearing after section headers

Root causes:
- \033[K only clears from cursor to end of line, leaving remnants when new messages are shorter
- stop_section_spinner was clearing lines even when no spinner was running

Changes:
- lib/core/base.sh:
  - Changed stop_section_spinner(), safe_clear_line(), safe_clear_lines() to use \033[2K
  - Added guard in stop_section_spinner to only clear when spinner is actually running
- lib/core/ui.sh:
  - Clear line once when starting spinner (before loop) to ensure clean start
  - Normal spinner rotation uses \r without clearing (performance optimization)

Performance: Line clearing happens only once per spinner start, not on every loop iteration.

Fixes #390
2026-01-31 10:09:02 +08:00
tw93
1e650d8144 fix: use \033[2K to fully clear spinner lines and prevent text remnants
Fixes text remnants showing when spinner messages change from longer to shorter text. Changed from \033[K (clear to end of line) to \033[2K (clear entire line) in stop_section_spinner(), safe_clear_line(), and safe_clear_lines() functions.

Fixes #390
2026-01-30 18:16:31 +08:00
tw93
e81be16031 perf: optimize scanner timer usage and app protection matching
- Replace time.After() with reusable timer to reduce GC pressure
- Use pre-compiled regex for app bundle matching (O(1) vs O(N))
- Fix Bash 3.2 compatibility (remove local -n usage)
2026-01-30 15:37:13 +08:00
tw93
89dcb0c3b5 fix: Use du -P for accurate size calculation and add timeouts to channel sends to prevent blocking. 2026-01-30 15:06:30 +08:00
tw93
2865a788e8 test: add checks for uninstallable Apple apps in should_protect_from_uninstall function 2026-01-30 13:57:43 +08:00
tw93
e96868824b feat: clean Apple Podcasts zombie StreamedMedia files (#387)
Add cleanup for sandboxed container tmp directory where zombie sparse
files can accumulate (0-byte files with ~93MB pre-allocated APFS blocks).
2026-01-30 11:19:51 +08:00
tw93
d06cf6a69e fix: correct blue color definition in base.sh 2026-01-30 11:13:29 +08:00
tw93
47ce6b0c50 Fix the issue with automated testing 2026-01-30 11:06:54 +08:00
tw93
87f605e9a8 test: add tests for cmd/status and conclude merge 2026-01-30 10:59:09 +08:00
Dylan Joss
b8e15b1c16 test: add tests for parsing and filtering functions (#385)
Add unit tests for parsing functions in `cmd/status/view_test.go`:
- `parseInt`: parses integers from strings with padding/decimals
- `parseRefreshRate`: parses display refresh rates from system output
- `isNoiseInterface`: filters noise network interfaces
- `parsePMSet`: parses macOS pmset battery output

Coverage for `cmd/status` improved from 8.4% to 12.6%.
2026-01-29 11:40:00 +08:00
tw93
d2e6917cce update supporters 2026-01-29 11:37:15 +08:00
tw93
3a7f15aa32 fix(check): use numeric df output for disk space 2026-01-29 11:15:14 +08:00
tw93
0a46bf2077 fix: improve status icons and fix spinner cleanup
- Show ✓ for empty trash and discovered versions (normal states)
- Fix inline spinner not stopping, causing residual display artifacts
2026-01-28 20:15:26 +08:00
tw93
88da841ce9 refactor: remove mo log command, keep log recording only 2026-01-28 19:58:59 +08:00
Tw93
c12f76c9f3 chore: auto format code 2026-01-28 11:46:59 +00:00
tw93
64f79a59d8 feat: optimize log system and add mo log command
- Add get_timestamp() helper and optimize log rotation
- Create mo log viewer with search/filter capabilities
- Improve test coverage to 18.4% with better assertions
- Add security fixes for grep injection prevention
2026-01-28 19:46:01 +08:00
Dylan Joss
f815a5f28c test: add tests for byte formatters and disk helpers (#382)
Add unit tests for additional utility functions in `cmd/status/view_test.go`:
- `humanBytes`: byte formatting with decimals and units
- `humanBytesCompact`: compact byte formatting
- `splitDisks`: separates internal/external disks
- `diskLabel`: generates numbered disk labels

Coverage for cmd/status improved from 6.9% to 8.4%.
2026-01-28 19:12:04 +08:00
tw93
52ba523579 fix(install): clear quarantine attribute after downloading binaries (#381) 2026-01-28 19:07:08 +08:00
tw93
6f0255c56e fix(uninstall): enhance app leftover detection with naming variants (#377) 2026-01-28 19:06:52 +08:00
tw93
ab4433d9c0 Merge branch 'main' of https://github.com/tw93/Mole 2026-01-28 11:43:41 +08:00
tw93
61a3238f19 fix(scan): prevent hang on cyclic symlinks (#378, #379) 2026-01-28 11:43:39 +08:00
Tw93
6036b4606c chore: auto format code 2026-01-28 03:26:51 +00:00
tw93
211fd21e10 Merge branch 'main' into dev 2026-01-28 11:25:33 +08:00
github-actions[bot]
87a24a0b3b chore: update contributors [skip ci] 2026-01-28 03:25:26 +00:00
Dylan Joss
a9c5794ec4 test: add tests for utility functions and heap implementations (#380)
Add unit tests for utility functions in cmd/status/view_test.go:
- formatRate: MB/s rate formatting with adaptive precision
- shorten: string truncation with ellipsis
- humanBytesShort: byte formatting with binary units

Add unit tests for heap implementations in cmd/analyze/heap_test.go:
- entryHeap: min-heap for dirEntry (basic ops, empty, single element)
- largeFileHeap: min-heap for fileEntry (basic ops, top N pattern)
2026-01-28 11:25:08 +08:00
tw93
7760b36c74 Update Security Review 2026-01-27 20:22:30 +08:00
tw93
8b9436e244 feat(check): detect third-party firewalls before built-in check
(#374)

    Support Little Snitch, LuLu, Radio Silence, Hands Off!, Murus, Vallum.
2026-01-27 20:04:29 +08:00
github-actions[bot]
54259d6df1 chore: update contributors [skip ci] 2026-01-27 11:43:12 +00:00
Gokul
9a109b2b39 fix(clean): handle singular 4K movie summary (#376) 2026-01-27 19:42:54 +08:00
github-actions[bot]
736bca14b5 chore: update contributors [skip ci] 2026-01-27 03:34:41 +00:00
tw93
37e6994c34 feat(clean): add Yandex Browser cache cleanup support 2026-01-27 11:34:21 +08:00
github-actions[bot]
9cd47133d1 chore: update contributors [skip ci] 2026-01-27 03:19:54 +00:00
github-actions[bot]
c53a0afc67 chore: update contributors [skip ci] 2026-01-27 03:19:45 +00:00
tw93
3f5e450001 Merge branch 'main' into dev 2026-01-27 11:19:18 +08:00
tw93
92de429817 update readme 2026-01-27 10:43:33 +08:00
tw93
9bb255238d update readme 2026-01-27 10:42:58 +08:00
tw93
1cf772b02c update readme 2026-01-27 10:41:38 +08:00
tw93
8c5d529171 update readme 2026-01-27 10:41:18 +08:00