fix: respect --dry-run in all cleanup functions#43
Open
qaz74107410 wants to merge 1 commit into
Open
Conversation
Several cleanup functions bypassed the dry-run flag by calling bare rm -rf / sudo rm -rf instead of the existing safe_rm / safe_sudo_rm helpers. Running with --dry-run would silently skip reporting deletions for CocoaPods, IDE caches, System Junk, browser caches, app containers, and Time Machine snapshots. Affected functions and changes: - cleanup_cocoapods: rm -rf → safe_rm -r - cleanup_ide_caches: rm -rf → safe_rm -r (use $HOME for paths with spaces) - cleanup_system_junk: sudo rm -rf → safe_sudo_rm -r; rm -rf → safe_rm -r - cleanup_browser_caches: rm -rf → safe_rm -r - cleanup_app_containers: rm -rf … || true → safe_rm -r - cleanup_timemachine_snapshots: guard tmutil delete call with $DRY_RUN check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Several cleanup functions bypassed the
--dry-runflag entirely by calling barerm -rf/sudo rm -rfinstead of the existingsafe_rm/safe_sudo_rmhelpers. Running./dev-cleaner.sh --dry-runsilently skipped reporting deletions for these sections, making the dry-run output incomplete and misleading.Affected functions:
cleanup_cocoapodscleanup_ide_cachescleanup_system_junkcleanup_browser_cachescleanup_app_containerscleanup_timemachine_snapshotsChanges
cleanup_cocoapodsrm -rf→safe_rm -rcleanup_ide_cachesrm -rf→safe_rm -r; use$HOMEfor paths with spacescleanup_system_junksudo rm -rf→safe_sudo_rm -r;rm -rf→safe_rm -rcleanup_browser_cachesrm -rf→safe_rm -r; use$HOMEfor paths with spacescleanup_app_containersrm -rf … || true→safe_rm -rcleanup_timemachine_snapshotstmutil deletelocalsnapshotswith$DRY_RUNcheckTest
The following script verifies that each affected function:
[DRY-RUN] Would delete …outputIt works by creating a mock
$HOMEunder/tmp, sourcing only the function definitions from the script, and calling each function withDRY_RUN=true.test_dryrun.sh
Result
Test plan
./dev-cleaner.sh --dry-runand confirm all 14 options now print[DRY-RUN] Would delete …lines for the previously silent functions--dry-runand confirm cleanup still works as expected