Renaming files or folders with Swish
If a file or folder already exists with the new name, a dialog appears asking if you would like to overwrite it. This is unlike the way Windows XP? and below work for normal filesystem operations. The normal behaviour of these versions of Windows is to refuse to rename the file and ask you to try again. I feel that our way is more useful and Microsoft seem to agree as Windows Vista? works this way too.
If confirmation is given, Swish attempts to overwrite the obstructing file or folder. Due to the limitations of SFTP versions 4 and below, most servers will not allow atomic overwrite (this is where the rename and overwrite happen in one, uninterruptable manoeuvre). We attempt to do this non-atomically by:
- appending ".swish_renaming_temp" to the obstruction's filename
- renaming the source file to the obstruction's old name
- deleting the renamed obstruction
If step 2 fails, we try to rename the temporary file back to its old name. It is possible that any of these steps may fail, and as this is non-atomic the temporary file would remain in place. It could be recovered by manually renaming it back.
It remains to be seen if this causes more problems than it's worth in which case we can always revert back to the Windows XP-style way of doing things.