atomicfile icon indicating copy to clipboard operation
atomicfile copied to clipboard

Fix windows panic on os.Rename when target file exists

Open thomasf opened this issue 10 years ago • 4 comments

Try to delete it first, but only on windows since it isn't atomic at all.

thomasf avatar Mar 09 '15 23:03 thomasf

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks!

facebook-github-bot avatar Mar 09 '15 23:03 facebook-github-bot

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

facebook-github-bot avatar Mar 10 '15 00:03 facebook-github-bot

This means it's no longer atomic :( Looks like https://msdn.microsoft.com/en-us/library/windows/desktop/aa365240(v=vs.85).aspx is one way to make this atomic on windows. I don't have a windows machine handy, but I think we should attempt to build an atomic version of this before we give up and go the os.Remove route.

daaku avatar Mar 10 '15 00:03 daaku

Yeah, I agree about it not being very good.. I should probably just have opened an issue instead..

Related golang issue planned for go1.5: https://github.com/golang/go/issues/8914

And here is an implementation: https://github.com/lvarvel/cacheddownloader/commit/505a1fdcc5af7823f20d7c87d9e4d1c833c59053'

I'm not really in a hurry getting this resolved right now.

thomasf avatar Mar 10 '15 01:03 thomasf