Skip to content

fix(cleanup): move scratch to the macOS Trash without opening it - #92

Merged
vishr merged 2 commits into
mainfrom
fix/macos-trash-without-full-disk-access
Oct 31, 2026
Merged

vishr merged 2 commits into
mainfrom
fix/macos-trash-without-full-disk-access

Conversation

@vishr

@vishr vishr commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

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.

vishr added 2 commits October 31, 2026 08:41
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.
@vishr
vishr merged commit 6a0adbc into main Oct 31, 2026
6 checks passed
@vishr
vishr deleted the fix/macos-trash-without-full-disk-access branch October 31, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant