Draft
Conversation
Adapted from the atomicwrites crate, but with directory fsync disabled for performance.
leiserfg
pushed a commit
to leiserfg/handlr
that referenced
this pull request
Mar 8, 2025
Bumps [h2](https://github.com/hyperium/h2) from 0.3.22 to 0.3.24. - [Release notes](https://github.com/hyperium/h2/releases) - [Changelog](https://github.com/hyperium/h2/blob/v0.3.24/CHANGELOG.md) - [Commits](hyperium/h2@v0.3.22...v0.3.24) --- updated-dependencies: - dependency-name: h2 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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.
Fixes #43.
I wrote my own atomic file saving module (
common::atomic_save). It was adapted from the atomicwrites crate, but with an added flag to disable directory fsync (atomicwrites always performs directory fsync). I chose to not fsync the directory after writing the file, because it's unnecessary to prevent corruption and hurts performance (to some degree I don't know). Note that my code depends on nix and does not compile on Windows (though I assume handlr is only meant for Unix platforms?).Both atomicwrites and my fork create a temporary directory within the folder (~/.config/) to write the temporary file to. I'm not sure why this is done instead of creating a temporary file directly in ~/.config/, but I didn't change it.
Note that atomicwrites doesn't use renameat2. There's an open bug report at untitaker/rust-atomicwrites#28, where some people have suggested that
renameat2is better suited for atomic saving. This is suboptimal and I haven't tried fixing it, but I don't think it's an issue for atomically saving mimeapps.list.Unfortunately this branch has "unused enum case" warnings because I moved atomicwrites from a crate to a module, and didn't use all enum cases in this program. The warnings would not be present if the code was located in a library crate. I'm not clear on the exact details of what causes the warning to happen or not, but there's some discussion on Reddit /r/rust.
Maybe this code should be upstreamed to atomicwrites. However it's an API-breaking change (requiring a new semver version) which they may or may not accept, so even if I did, you'd have to wait for atomicwrites to be updated.