New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dirext: Rewrite using cap_tempfile::TempFile
#12
Merged
Merged
Conversation
This file contains 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
cap-std 0.24.3 is now released, with the |
Now that all the core logic has been drained into `cap_tempfile::TempFile` in bytecodealliance/cap-std#239 we can just use it directly. NOTE: This changes the semantics of some of the APIs; the previous `replace()` API tried to do "reuse previous file mode if it existed" but I think that's just a confusing trap. Anything writing the file in the general case needs to know the permissions it wants to use.
This more clearly says what we're doing; this is really the key property versus "std" APIs like `std::fs::write`. It helps match up with this crate: https://lib.rs/crates/atomicwrites
Now that we don't need to propagate `Permissions` everywhere, add the obvious replacement for `std::fs::write`.
This can be implemented in the closure-based API by just calling `set_permissions()` alongside writes.
Now that we use `cap_tempfile` which is portable, we can with just a little bit of effort be portable too.
Thanks! Rebased 🏄 and lifting draft. |
jmarrero
approved these changes
May 3, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Patch to port rpm-ostree:
|
jlebon
added a commit
to jlebon/ostree-rs-ext
that referenced
this pull request
Jun 24, 2022
We use `atomic_write` which was added in 0.25: coreos/cap-std-ext#12
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.
This needs a new
cap_tempfile
release with bytecodealliance/cap-std#239Drop
LinkableTempFile
, usecap_tempfile::TempFile
Now that all the core logic has been drained into
cap_tempfile::TempFile
in bytecodealliance/cap-std#239we can just use it directly.
NOTE: This changes the semantics of some of the APIs; the previous
replace()
API tried to do "reuse previous file mode if it existed"but I think that's just a confusing trap. Anything writing the file
in the general case needs to know the permissions it wants to use.
dirext: Use "atomic" terminology
This more clearly says what we're doing; this is really the key property
versus "std" APIs like
std::fs::write
.It helps match up with this crate:
https://lib.rs/crates/atomicwrites
dirext: Add a basic
atomic_write
Now that we don't need to propagate
Permissions
everywhere,add the obvious replacement for
std::fs::write
.Drop
atomic_replace_file_with_perms
This can be implemented in the closure-based API by just calling
set_permissions()
alongside writes.Build on Windows
Now that we use
cap_tempfile
which is portable, we canwith just a little bit of effort be portable too.
dirext: Improve and fix docs