Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stack: check close(2) before publishing NamedTempFile to cache
Close *can* fail for real I/O reasons, and while it would be ideal to always fsync: 1. that's an (opt-out) option 2. it can still be nice to detect post-fsync failures 3. with NFS close-to-open consistency, closing is the most reliable way to make the file's contents globally visible. In general, Kismet works on paths, not files, so there's not much we can do about closing (or not) the underlying File object before publishing it. For `NamedTempFile`s though, we get both a file and a path! We can extract the file, make sure it's ready for publication (world readable, fsync-ed if necessary, and then closed) before passing the `TempPath` to Kismet's usual path-based machinery. This `TempPath` is what keeps the temporary file path alive, so everything will still be cleaned up on error, even though the file descriptor itself is long gone. Of course, Rust doesn't yet have an `Error`-ful `File::close`, so we roll our own with libc...
- Loading branch information
Showing
2 changed files
with
72 additions
and
51 deletions.
There are no files selected for viewing
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
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