Repository navigation
fix(cleanup): move scratch to the macOS Trash without opening it - #92
Merged
Merged
Conversation
macOS privacy protection refuses to open ~/.Trash to a process without Full Disk Access, as the Driga service is, so every scratch removal failed with "trash rename (same filesystem required): operation not permitted": the move opened the trash directory to rename into it. Such a process may still rename an item into ~/.Trash. On macOS the move now goes through a handle on the trash's parent, checks that .Trash is a real directory on the same device, and renames with RENAME_EXCL so an existing item is never replaced. Linux keeps the handle on the trash directory. The error names "same filesystem required" only for a cross-device move.
…the Trash Address review: rename with RENAME_EXCL|RENAME_NOFOLLOW_ANY on macOS and RENAME_NOREPLACE on Linux, and retry a trash name taken since the free-name 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.
fix(cleanup): move scratch to the macOS Trash without opening it
macOS privacy protection refuses to open ~/.Trash to a process without Full
Disk Access, as the Driga service is, so every scratch removal failed with
"trash rename (same filesystem required): operation not permitted": the move
opened the trash directory to rename into it. Such a process may still
rename an item into ~/.Trash.
On macOS the move now goes through a handle on the trash's parent, checks
that .Trash is a real directory on the same device, and renames with
RENAME_EXCL so an existing item is never replaced. Linux keeps the handle on
the trash directory. The error names "same filesystem required" only for a
cross-device move.
Review follow-up: on macOS the rename uses RENAME_EXCL|RENAME_NOFOLLOW_ANY, so a symlink anywhere in the destination is refused and an existing item is never replaced; the kernel refuses a cross-device move. Linux uses RENAME_NOREPLACE where the filesystem supports it. A trash name taken since the free-name check is retried with the next name. Checked with a launchd job without Full Disk Access: the rename into ~/.Trash succeeds.