1. Have two directories for the app: A and B. One contains the "current" version and one contains (possibly) the "next" version.
2. Have the actual app you start be a separate launcher program that just picks which version to launch.
3. While the app is running, periodically check for updates. If an update is available download and unzip it to the A or B directory that isn't currently in use.
4. Next time the launcher program starts it can say "an updated version is already installed, would you like to use it" (or you can just do that automatically if you - or your user - decide that's the best option). If so it marks the appropriate A/B directory as "current" and launches that one.
Zero delay for users, works on all OSes, works with "always use the latest version" as well as "ask the user to update".
I've never tried this tbf - just an idea.
[1] Technically speaking I believe this can be solved with transactional NTFS (deprecated but still available as of Windows 11, AFAIK).
And yet it's running on windows?!
saagarjha•2h ago
If you do this on macOS, and your code is codesigned, you are setting yourself for pain. Instead you should replace the file entirely so the file gets a new vnode.
piker•2h ago
[EDIT: the post has been updated for this point. Thanks so much. https://tritium.legal/blog/update#3.]
saagarjha•2h ago
silon42•1h ago
It covers more cases: either a new instance is starting, or it hasn't fully loaded the file yet.