Skip to content

fix: bind removals to scanned roots and preserve XDG trash recovery - #80

Open
phibkro wants to merge 1 commit into
tobi:mainfrom
phibkro:fix/filesystem-safety
Open

phibkro wants to merge 1 commit into
tobi:mainfrom
phibkro:fix/filesystem-safety

Conversation

@phibkro

@phibkro phibkro commented Oct 11, 2026 •

Copy link
Copy Markdown

Reproduction

On origin/main, replacing the scanned root redirects planned removal, and replacing an intermediate parent redirects the built-in XDG trash fallback so it moves an outside file. Throwaway tests against origin/main (not included here) failed for both, and also showed permissive modes on newly created trash directories and exhausted trash names reusing an occupied name. A follow-up regression, same_named_trash_entries_keep_distinct_metadata, failed on an earlier revision of this branch when an orphaned .trashinfo reserved the next same-name suffix (0 passed / 1 failed, AlreadyExists).

Fix

Retain the scan-start root identity and verify the opened root descriptor against it before deleting. Normalize platform stat widths and compare source and trash devices through opened descriptors. Create new trash directories privately (0700) and reserve metadata (0600) with exclusive creation before the payload moves. Payload and metadata names match, occupied metadata names are skipped, and native NOREPLACE prevents a payload overwrite. A metadata failure leaves the source intact; a failed payload move removes its reserved record. Existing directory permissions are unchanged. Rustix native NOREPLACE is used on Apple as well as Linux and Android; other Unix platforms refuse the built-in trash rather than use a racy rename fallback. No new dependencies.

Checks run

cargo xtask lint passed. cargo xtask test passed: 72 app, 148 core (2 ignored), 3 xtask. The exact core tests for matching metadata, real-source exhaustion, existing modes, metadata failure and failed-move cleanup each passed (1 passed). cargo check -p disktree-core --target x86_64-apple-darwin --tests passed.

Limitations

macOS compilation is not runtime verification. Windows: cargo check -p disktree-core --target x86_64-pc-windows-msvc --tests passes; nothing was run on Windows. External and native trash backends were not exercised; their path races and final-target identity changes are not claimed solved. Two mount fixtures remain ignored.


Developed with AI assistance (OMP agents). I reviewed the diffs; every check listed was run on the final branch.

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