I implement a simple update mechanism for the application that I am writing, the last part of the update process is to rename the current application executable from something like myApp.exe to myApp.old.exe, and then rename the downloaded and updated file from myApp.new. exe in myApp.exe.
I would like to find a way for the two operations to be atomic, because if my application crashes (for some reason, like asteroids falling on a power line) after it renamed itself and before it renamed the new version, it will get stuck in a state where it cannot be restarted using regular shortcuts, so it will not be able to complete its update.
So, is there a way to make the upgrade fail-safe?
source
share