Repository navigation
feat: move folders to the Trash instead of deleting them - #9
Merged
Merged
Conversation
A folder removed by mistake can be dragged back out of the Trash. sweep never deletes anything itself any more. The Trash is ~/.Trash, or the disk's .Trashes/<uid>; the move is one renameatx_np (RENAME_EXCL) from the parent Remove holds open, after every existing check. Folders are named after where they came from ("Code › web › .next"). The scan never enters Trash folders, and tests never touch the real Trash.
The recording gets a home of its own, so the two folders it moves go to demo/home/.Trash, which make demo removes, not to your Trash.
|
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.
sweep no longer deletes anything. Every folder it removes goes to the Trash, so one removed by mistake (by you or by sweep) can be dragged back out.
What changes
~/.Trash, or.Trashes/<uid>on an external drive, like Finder. sweep creates it if it's missing. If a disk has no usable Trash, sweep stops before scanning.-nstill works there.renameatx_npwithRENAME_EXCL, made from the parent folderRemovealready holds open. It moves exactly the folder the scan saw, never overwrites anything in the Trash, and is instant whatever the folder's size.Code › web › node_modules. Starting with the projects folder's name also keeps.nextand similar folders visible in Finder..Trashor.Trashes, and neither can be a target intargets.conf.HOME, somake demonever touches your Trash.There's no flag to delete for good. That's deliberate, to keep sweep predictable.
Testing
go test -race ./...passes on an Apple Silicon Mac. Tests use a temporary Trash (TestMain) and never touch the real one.FindTrash, a disk-image volume's.Trashes, and the screen's wording. The random-use safety test now runs against a Trash.-yagainst the real~/.Trash.~/.Trashintact.🤖 Generated with Claude Code