tf2classic / TF2CDownloader

Cross-platform utility for automatically downloading and installing TF2 Classic
GNU General Public License v3.0
48 stars 13 forks source link

Initial ugly work on an updater #24

Closed chloecormier closed 2 years ago

chloecormier commented 2 years ago

This is a quick and dirty implementation. There's a lot more I'd like to add (particularly, delta-based diffs for updating the game, and authentication to verify the remote versions.py file is signed by us) but, in case we push any small updates soon, I wanted this to be on the table.

Localization hasn't been touched yet, outside of importing gettext and using it for all new strings in updater.py

The meat and potatoes of this commit is just about update checking. We parse version.txt to get the game's semantic version with punctuation removed (for instance, 203) and store this number in rev.txt for later use, then we compare this against a remote version database, which also specifies what the latest and previous versions of the game are.

If the user has the previous version of the game, we'll offer to update. If they're two or more versions out-of-date, we keep it simple by just downloading and extracting a full archive again. This avoids an issue with the old launcher where, if the user was going from 2.0.0 to 2.0.3, it would download every intermediary patch, which was a larger download than just downloading the game from scratch.

This also more intelligently asks the user if they want to reinstall/repair the game if there's an existing up-to-date installation, instead of blindly overwriting anything.

The actual updating process isn't any more complex than just pulling a remote archive and extracting it over the existing game install. It's a clone of the normal installation code with a different meta4 file and archive name, in effect.

Right now, none of this works because there is no new update, hence there's no patch archive for it to download. Once a 2.0.4/2.1.0 is available though, changes only need to be made to https://tf2classic.org/updater/versions.py, this code is maintenance-free for new releases.

Still, I'd like a general review of the implementation as it stands.