I'm trying to do an atomic update of a file using Net::SFTP.
Typically what I would do is write to "file.tmp", then rename to "file" when complete.
What I find is that Net::SFTP::do_rename() fails if the file I am renaming to already exists. If I use do_remove() of the old file prior to the do_rename() it all works fine, but then there is an (albeit small) window between the do_remove() and do_rename() where the file doesn't exist.
Is there some other technique I should be using to update the file over SFTP?