thpatch / thcrap

Touhou Community Reliant Automatic Patcher
https://www.thpatch.net
The Unlicense
558 stars 41 forks source link

Add the possibility to abort an update checking #128

Open babouaya opened 4 years ago

babouaya commented 4 years ago

Sometimes the server is SLOW, so slow that I launch a game and I'm stuck for a loooong time on the "check for update" phase. Please allow me to skip this check when it's too slow.

32th-System commented 4 years ago

You can disable updates entirely by renaming thcrap_update.dll in the bin folder to something else

babouaya commented 4 years ago

This is a workaround, I can also choose to check for update after the game has run, but neither are a proper solution IMHO.

brliron commented 4 years ago

tl;dr that might not be needed in the future, but I think I'll do it anyway.

First, that's the perfect time to suggest that. I agree that the updates at startup tend to be too slow, so I am in the progress of rewriting the update code (well, not really because I spend less time on side projects since the lockdown started here. But it will happen eventually). Which means this is the perfect moment to change how the updates work, and eventually make them cancellable.

Now, why they aren't cancellable, and why it's hard to make them cancellable (if you don't care about these details, you can skip this paragraph): The update has 3 parts: check for a new thcrap version, check for "core files" updates, and check for "game-specific" updates. Check for a new version need to happen first, because the other files might depend on another feature. Cancelling it shouldn't be a problem. Checking for the core files is the hard part. We download one file, then install it, then another file, then install it... which means we can have a partial update. And one file might depend on another one. Which means, if you cancel it in the middle, the game might not work. One solution could be to store everything in ram, and write them to the disk only when everything have been downloaded, which means you either have the full update or throw everything. And finally, the game-specific updates. They tend to be translations or images, they usually have zero dependencies, we don't care if you cancel them in the middle (and you can already do it by clicking on "run the game", the button becomes clickable when this step starts). Another scenario to keep in mind is if you update thcrap, then restart, then cancel the updates before updating the core files. I think we tend to keep new thcrap versions compatible with old files, and even if we don't, someone would need to stay during half the update (the thcrap part), then decide in the middle to cancel the "core files" part. I think this scenario is rare enough and unlikely enough to be ignored.

And finally, you might not need to cancel them in the future. As I said, I'm in the progress of rewriting the update code, and I hope it will make the update checking faster. But it might not work, or it might still be too slow for some people with a bad connection, or the servers might be especially slow one day, or some people may be behind a proxy / firewall and have to wait until they get the timeout because the proxy / firewall decided to forbid and drop the connection, so I think this is still a feature worth having. Don't get too hyped up, programming takes times, and I don't have a lot. Don't expect that to happen within a week. But I think it will happen eventually.

babouaya commented 4 years ago

what if the updated files were downloaded in a temporary location and applied once the whole is complete ?

brliron commented 4 years ago

Yeah, I thought about that after writing my message