1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 19:40:07 +00:00
Commit Graph

638 Commits

Author SHA1 Message Date
tw93
c8190772ac refactor(core): remove unused utility functions
Remove unused functions from base.sh and ui.sh:
- base.sh: is_interactive, spinner stack management, get_terminal_info, validate_terminal_environment
- ui.sh: with_spinner

Net reduction: ~166 lines of dead code
2026-02-28 15:25:53 +08:00
tw93
2f1985ad6f fix(clean): clear spinner remnants after stopping
Add extra terminal clear to prevent spinner character remnants
when cleaning project caches.
2026-02-28 14:57:45 +08:00
tw93
60624f951b fix(clean): respect whitelist in Homebrew dry-run mode
Show "skipped whitelist" instead of "would cleanup" when Homebrew cache
is whitelisted, making dry-run behavior consistent with actual execution.
2026-02-28 14:57:44 +08:00
tw93
9d89bab922 fix(uninstall): run LaunchServices refresh async so Press Enter prompt appears immediately 2026-02-28 11:28:03 +08:00
tw93
d2820eeb2e fix(uninstall): sync LaunchServices refresh for Spotlight update, remove background hint message, close #490 2026-02-28 11:22:41 +08:00
tw93
75dc9f01dc refactor(clean): use assignment form for arithmetic increments in safe_clean 2026-02-28 11:22:35 +08:00
Tw93
194e8ad29a chore: auto format code 2026-02-28 03:11:16 +00:00
tw93
c19a0276b8 refactor: Update shell arithmetic increment syntax from ((var++)) || true to var=$((var + 1)) across various scripts. 2026-02-28 11:10:18 +08:00
tw93
7d70889ad4 chore: auto format code 2026-02-28 11:03:16 +08:00
tw93
1be71edc9d fix: use Base-10 sizes and mdls logical size to match macOS Finder
- Switch bytes_to_human (shell) and humanizeBytes (Go) from Base-2
  (1024) to Base-10 (1000) to match Apple's storage calculation
  standard since Snow Leopard
- Add proper decimal rounding instead of truncation
- Use mdls kMDItemLogicalSize for .app bundles to avoid APFS clone
  file undercounting by du

Fixes #511
2026-02-28 10:02:34 +08:00
tw93
646ff72a96 fix(clean): resolve unbound variable 'mount_points[@]' error in empty array case (#511) 2026-02-28 09:53:07 +08:00
Tw93
61cf5271eb chore: auto format code 2026-02-28 01:50:15 +00:00
tw93
310abb2510 fix: clean aerial wallpaper videos directly without 30d limit and bypass app protection wildcard, close #508 2026-02-28 09:49:16 +08:00
tw93
5710679809 fix: skip Time Machine checks when not configured, close #510
Use a fast `defaults read` pre-check before spawning any tmutil
process. On machines without Time Machine configured the check
returns instantly, avoiding the spinner and the 2-3s tmutil timeout.

Affected locations:
- lib/clean/system.sh: clean_time_machine_failed_backups()
- lib/clean/system.sh: clean_local_snapshots()
- lib/clean/user.sh: local snapshot hint in system hints
2026-02-28 09:35:08 +08:00
Tw93
922f5f1fc9 feat: add cleanup for aerial wallpaper videos
Add support for cleaning old aerial wallpaper videos in:
/Users/user/Library/Application Support/com.apple.wallpaper/aerials/videos

These video files can consume significant disk space (up to 50GB+) and
are safe to remove - macOS will re-download them on demand.

Uses MOLE_SUPPORT_CACHE_AGE_DAYS (default 30 days) to avoid removing
recently used wallpapers.

Closes #508
2026-02-27 23:46:40 +08:00
Tw93
c129591cf4 fix: remove redundant pipefail blocks and fix arithmetic bug
This commit addresses the issue #506 where mole would exit prematurely
during application support scanning.

Changes:
1. Remove 4 redundant pipefail disable/restore blocks:
   - safe_find_delete() in lib/core/file_ops.sh
   - safe_sudo_find_delete() in lib/core/file_ops.sh
   - fix_broken_preferences() in lib/optimize/maintenance.sh
   - opt_saved_state_cleanup() in lib/optimize/tasks.sh

   These were unnecessary because process substitution (< <(cmd)) is not
   affected by pipefail - only real pipelines (cmd1 | cmd2) are.

2. Fix real bug in fix_broken_preferences():
   - Add || true to ((broken_count++)) on lines 35 and 55
   - This prevents set -e from exiting when broken_count starts at 0

Fixes #506
2026-02-27 23:44:10 +08:00
Tw93
a8065dfbae fix(application_support_logs): prevent process substitution failures by temporarily disabling pipefail 2026-02-27 23:20:04 +08:00
Tw93
013549ad25 fix: temporarily disable pipefail to prevent process substitution failures during cleanup operations 2026-02-27 22:52:38 +08:00
tw93
a9433e4acd fix: preserve interrupt semantics and restore purge traps 2026-02-27 11:18:53 +08:00
tw93
0341ae6648 perf(clean): speed up memory report size pre-scan 2026-02-27 09:53:27 +08:00
tw93
2eb0f2b9b3 fix(log): generate summary divider width from terminal width
Replace hardcoded 70-char string with a dynamically generated divider
capped at terminal width (max 70) so the separator fits narrow terminals
instead of overflowing them.
2026-02-26 19:42:58 +08:00
tw93
6c0aa87389 fix(clean): guard DRY_RUN against unbound variable in system.sh
Change "$DRY_RUN" to "${DRY_RUN:-}" so the check is safe under
set -euo pipefail when DRY_RUN is not exported by the caller (e.g.
unit tests that source lib/clean/system.sh directly without going
through bin/clean.sh which initialises the variable).
2026-02-26 19:42:52 +08:00
tw93
d13c0927a6 feat(purge): add confirm dialog, two-pass column alignment, adaptive footer
- Add confirm_purge_cleanup() to show item count + size and require
  explicit Enter/y confirmation before any deletion
- Two-pass layout in clean_project_artifacts: pass 1 collects data,
  pre-scan finds max path and artifact widths, pass 2 formats with
  consistent column alignment across all rows
- Adaptive footer hints in select_purge_categories degrade gracefully
  on narrow terminals (full → reduced → minimal)
- Use printf '\033[J' to clear stale content when list height shrinks
- Guard empty-array expansions with ${arr[*]-} for set -u safety
- Add BATS tests for confirm_purge_cleanup (Enter confirm, ESC cancel)
2026-02-26 19:42:42 +08:00
tw93
e17f35eb57 fix(uninstall): show next-step prompt without post-cleanup delay 2026-02-26 16:43:09 +08:00
tw93
aa1a436862 fix(clean): improve loading feedback and spinner output 2026-02-26 16:36:06 +08:00
Tw93
b3f023b5e6 chore: auto format code 2026-02-26 03:54:50 +00:00
tw93
29ec8f7d43 style(clean): unify DRY_RUN variable check style
Use consistent "$DRY_RUN" check instead of "${DRY_RUN:-false}"
to match project conventions.
2026-02-26 11:53:54 +08:00
tw93
3e47cdb39e refactor(uninstall): use shared get_lsregister_path from base.sh
Remove duplicate get_lsregister_path() implementation and use the
shared utility from base.sh instead.
2026-02-26 11:53:49 +08:00
tw93
d0e1a200d6 refactor(optimize): use shared get_lsregister_path from base.sh
Remove duplicate get_lsregister_path() implementation and use the
shared utility from base.sh instead.
2026-02-26 11:53:44 +08:00
tw93
88b0fe6af3 refactor(base): extract get_lsregister_path as shared utility
Move get_lsregister_path() to base.sh to avoid duplication across
optimize and uninstall modules. Adds macOS 14+ compatibility with
fallback paths.
2026-02-26 11:53:39 +08:00
tw93
980bbcd3c3 fix(uninstall): improve LaunchServices path detection for macOS 14+
- Add fallback paths for lsregister tool
- Check executable permission before using path
2026-02-26 11:47:46 +08:00
tw93
3bd3e400b6 style: improve code consistency and formatting
- Rename _MOLE_HINTS_DIR to mole_hints_dir (naming convention)
- Split local variable declaration and assignment
- Add ICON_INFO constant to base.sh
- Remove redundant has_cached_sudo function (use has_sudo_session)
2026-02-26 11:47:41 +08:00
tw93
3c3c976b5b fix(optimize): use ICON constants and improve LaunchServices path detection
- Replace Unicode characters with ICON_SUCCESS and ICON_INFO constants
- Add fallback paths for lsregister tool (macOS 14+ compatibility)
2026-02-26 11:47:33 +08:00
tw93
ceac7957aa fix(clean): correct Messages check logic and improve Application Support scanning
- Fix Messages running check to not skip CrashReporter/idleassetsd cleanup
- Add proper spacing between function definitions
- Add app_support_item_size_bytes() for accurate size calculation
- Improve progress reporting during Application Support scan
2026-02-26 11:47:28 +08:00
tw93
5d69968ac0 perf: improve Application Support scan progress and size accounting 2026-02-26 10:33:19 +08:00
诺亚Q
dc7380d5b2 fix: avoid hang on large Application Support directories (#495) (#496)
Replace du traversal + double find with single find -print0 + stat -f%z
to eliminate 8+ minute hang on directories with 392K files. Add progress
feedback via update_progress_if_needed in the outer loop.
2026-02-26 10:29:46 +08:00
tw93
258d78991a fix: refresh launchservices after app uninstall 2026-02-24 14:26:33 +08:00
tw93
db602a0022 fix: skip font cache rebuild when browsers are running 2026-02-24 14:23:00 +08:00
tw93
8bd257a9c2 refactor(purge): reuse shared size formatter in header 2026-02-24 14:20:25 +08:00
Angelk90
ae5e81722b Fix (#486) 2026-02-24 14:17:20 +08:00
tw93
3e3594dc58 fix(clean): avoid false success for third-party log cleanup 2026-02-23 13:39:27 +08:00
tw93
ff00e9ba9c refactor(clean): extract shared purge hint helpers 2026-02-23 13:39:22 +08:00
tw93
4c9a71315f refactor(ui): unify action and list hints across commands 2026-02-23 11:34:22 +08:00
tw93
3112673ed3 feat(clean): add storage clues after large files 2026-02-23 11:34:04 +08:00
tw93
1169cbf198 fix(purge): avoid command find in fallback scan (#478) 2026-02-23 08:15:47 +08:00
tw93
8f5b70457e fix(purge): normalize search roots for scan filtering (#478) 2026-02-22 22:06:19 +08:00
tw93
fd5ceea743 feat(clean): expand conservative cache cleanup coverage
- add conservative support/app/system cache targets\n- fix dry-run + success logging behavior for memory exception cleanup\n- add regression tests for new cleanup paths and safeguards\n\nRefs #477
2026-02-22 11:06:48 +08:00
tw93
894c81bb9a fix(purge): detect artifacts when search path is project root 2026-02-22 10:08:20 +08:00
tw93
ec3affe882 chore(clean): reduce noisy clean output messages
- remove redundant project cache scanning line

- align xcode runtime empty result message to already clean
2026-02-21 23:48:07 +08:00
tw93
16a8bcafde chore(dev-clean): streamline runtime volume reporting
- reduce noisy scan output outside debug mode

- consolidate final result messaging

- run xcode/code editor stages explicitly in developer flow

- update dev cache tests for new stage calls
2026-02-21 23:36:05 +08:00