feat(tools): add PurgeArchives, an age-based purge with a fail-closed directory guard - #1794
Open
xmasyx wants to merge 1 commit into
Open
feat(tools): add PurgeArchives, an age-based purge with a fail-closed directory guard#1794xmasyx wants to merge 1 commit into
xmasyx wants to merge 1 commit into
Conversation
… directory guard Deletes files older than N days (default 14) inside an archive directory, sparing anything prefixed KEEP-. The guard is the point: it refuses any directory whose basename is not exactly the sentinel (--dir-name, default _archive), so it cannot be pointed at live work by a bad argument. Files only, never subdirectories, dotfiles skipped, --dry-run touches nothing. Requested in danielmiessler#1614.
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.
Offered in #1614; you said yes to (5).
Deletes files older than N days (default 14) inside an archive directory. A manual archive is a grace window, not forever: silence means it goes after N days, a
KEEP-prefix means it stays. The trigger is lazy, called right after archiving something by hand, so the directory prunes itself as a side effect of being used and there is no scheduler.The guard is the reason to take it. It refuses any directory whose basename is not exactly the sentinel (
--dir-name, default_archive). A tool that deletes by age is one bad argument away from deleting live work, so the check is not "this path looks plausible": the directory has to be named as an archive, which is a property no working directory acquires by accident. Files only, never subdirectories; dotfiles skipped; every action logged;--dry-runtouches nothing.Verified against a fixture tree, case by case: pointed at a live directory it refuses with exit 1 and leaves the contents intact;
--dry-runprints and deletes nothing; the real run removes only the expired non-KEEP-file whileKEEP-, fresh files, dotfiles and subdirectories all survive; the sentinel override works;--days abcis rejected with exit 1.