我从未尝试过,但这是我的猜测(假设您无法覆盖正在执行的文件。如果可以的话,这一切都更简单)
Updater A checks if its the newest version
If launcher isnt the newest version
Download the differences (to save bandwidth) to file B
Apply the delta to own code into file C
Launch file C.
Close
If file C exists (update happened recently)
Try to delete C (update was previous launch, delete temporary file)
If delete fails (We are C, means A is out of date)
Copy C over A (update launcher)
Note that you can keep going, dont have to restart even though we are C.
If game isnt newest version
Download the differences (to save bandwidth) to file B
Apply the delta to game into file D
delete game
Rename D -> game
Run game
André Caron 向我展示了交换技巧在事务性文件 IO 中做得更好。