natefinch / atomic

atomic is a go package for atomic file writing
MIT License
200 stars 12 forks source link

Fails if your temp directory is on a different physical drive #3

Closed natefinch closed 5 years ago

natefinch commented 7 years ago

The code currently writes a temp file in your temp dir and then tries to rename it over to the real filename. However, this fails if your temp directory is on a different physical drive (this makes sense, there's no atomic way to actually transfer bytes from one disk to another).

Will require a fix to write the temp file to the same directory as the real file, with a unique name, and then rename.

heyimalex commented 6 years ago

This is your project so you know better than me, but are you sure this is an issue? You do filepath.Split to get the directory of the destination filename and then pass that to ioutil.TempFile, so the created temporary file is always in the same directory.

itchyny commented 5 years ago

I agree with @heyimalex's comment, I think the code is correct and guarantees the temp file to be on the same directory (i.e. same drive).

natefinch commented 5 years ago

Ha, yes, thank you, I think this is an old bug that got fixed and then never closed.