First off, thank you @natefinch and all for putting this tool together!
I have the following usecase and wonder if this project can be extended to support it: today, atomic.WriteFile() uses io.Copy() to do the actual I/O to the temporary file. io.Copy is called with os.File and io.Reader, which makes a lot of sense for most cases. I have a particular case where I would like to override the I/O behavior, but still have the file write be atomic.
Can we consider introducing a new function NewWriter() (or WrapWriter()), like so:
func NewWriter(w func(filename string, r io.Reader) error) func(string, io.Reader) error {
return func(...) error {
// Create temp file
// Call w
// Sync and rename resultant file
}
Is this within the purview of the project? If so and if people are happy with this proposal, I am happy to submit a PR for this. Thanks!
Hello @natefinch, checking in on this again. The downstream issue https://github.com/kopia/kopia/issues/1887 remains open. Do you think we can merge the PR #22 to address this? Thank you!
First off, thank you @natefinch and all for putting this tool together!
I have the following usecase and wonder if this project can be extended to support it: today,
atomic.WriteFile()
usesio.Copy()
to do the actual I/O to the temporary file.io.Copy
is called withos.File
andio.Reader
, which makes a lot of sense for most cases. I have a particular case where I would like to override the I/O behavior, but still have the file write be atomic.Can we consider introducing a new function
NewWriter()
(orWrapWriter()
), like so:Is this within the purview of the project? If so and if people are happy with this proposal, I am happy to submit a PR for this. Thanks!