Updating in place is dangerous -- if anything serious happens while saving the file, the user is left with a corrupted file. Much safer is to write the new contents to a new file (in the same location as the target file) and renaming after writing is complete. This also resolves any potential issues with hard links (that's how I discovered this problem).
Anonymous
Right, that is an issue we need to address.
But not likely to happen
But I like this how it is.
I only hard link files, if I want them to stay the same, even after one copy is edited.
Ticket moved from /p/texstudio/bugs/1414/
Using hard links to files for the purpose you mentioned (ensuring file contents are the same) seems brittle to me. Links to directories are perfectly fine, but there's only soft links (or junctions on Windows) for directories.
Another possible application of hard-linking is to quickly create a snapshot of a directory tree (without actually copying the contents), to be able to work in the one directory tree without altering the contents of the other directory tree. However, this breaks if files are edited in-place.
Anyway, now that I'm aware of the behavior of TeXstudio, I can adjust mine ;-)
Some other questions that come to my mind in that context.
) did not mean the implementation, but that a situation where the current function loses data is unlikely
Alright. :) We would have a very big problem already if it was otherwise.
implemented: hg 5644 (c1c891d40d41)
Instead of the original proposal, I chose to copy the original file and move it back in case of an incomplete save operation. This has the advantage that we still write on the original file and thus handles cases 1. and 2. mentioned above gracefully. There's an extra cost for copying instead of renaming, but it's negligable.