-
Notifications
You must be signed in to change notification settings - Fork 9
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
I would like to have a variant of the Commit method that fails on EEXIST #9
Comments
I'm not sure using Darwin:
Linux:
Not sure what to do on Windows, though. Also, this will complicate the package a lot and needs tests on different kernel versions and filesystems. |
I suggested old-fashioned link(2) because I think it's portable to any posix system and ought to do the right thing on any filesystem supporting hard links at all. And I'd also expect it to fail in an obvious way if you try it on something like an MSDOS filesystem. I'm afraid I'm not that familiar with Darwin or Windows, or with the details of Go stdlib glue to relevant syscalls. I understand that appropriate unit tests will likely be more code than than the feature itself. I'll probably give implementation a try, unless you think it's a great idea and want to add it pretty soon yourself. |
Ping? I prepared a pull request some month ago, which seems to work fine for my usecase. |
Sorry, I'm currently busy with other things, so this package lacks maintenance. Please feel free to use/promote others to use your fork of this project for now. |
I see. For reference, this is what I have in the go.mod file in the project that needs this feature:
If anyone else needs this, please reach out, since this fork is currently aimed only for our own use in the sigsum project. |
The usecase I have is atomic create of a file (with contents): I (i) want the file to appear at the given name only after it has been successfully written and synced to disk, but (ii) if some file with the given name already exists at commit time, I don't want to replace it, I want the commit operation to fail and leave the existing file untouched.
This could be implemented as a method CommitIfNotExists, using the link(2) syscall rather than rename(2), and explicitly removing the temporary file on success.
The text was updated successfully, but these errors were encountered: