Skip to content
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

Allow user to wrap an existing write function #21

Open
adowair opened this issue Apr 12, 2022 · 1 comment
Open

Allow user to wrap an existing write function #21

adowair opened this issue Apr 12, 2022 · 1 comment

Comments

@adowair
Copy link

adowair commented Apr 12, 2022

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!

@adowair
Copy link
Author

adowair commented Dec 1, 2023

Hello @natefinch, checking in on this again. The downstream issue kopia/kopia#1887 remains open. Do you think we can merge the PR #22 to address this? Thank you!

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 a pull request may close this issue.

1 participant