Answer the question
In order to leave comments, you need to log in
What is the correct logic for updating the game client?
Hello. There was a need to create an application that is a kind of "launcher" (launcher) for one game.
The only hitch I've run into is updating the game files properly.
There are two types of updates:
Answer the question
In order to leave comments, you need to log in
From personal experience: imho the most correct thing is to have an unbreakable chain of updates from the first version to the current one, i.e. 1>2, 2>3, 3>4, etc.
Periodically release major versions for a clean installation, but still have an unbroken chain of updates.
Making patches like 1>4, 2>4, etc. - in my experience, archi is wrong, because it creates huge risks of implicit bugs + the cost of assembling such patches.
In fact, there is no problem for the user to install many updates.
A check will be made to see which of the blocks of numbers in the version is different.You are discussing some small details.
How do they check for the presence of even the most unnecessary file? Deleted the file from the directory, and he takes and downloads it. Checks before start all directories on the time of change and compares with server?Attaching to the date of the changes is not a good idea. The check goes through the directories recursively, compares not only the list of files but also their hashes. Read how dropbox / Yandex.disk works, and finally the same torrent
Question three: How effective will it be to compare the change time of directories for the user and compare with server ones? After all, even if a file was changed/deleted/created in the deepest directory, then the directory at the top in the hierarchy will have the date of the change when the file was affected. Accordingly, a large number of recursive checks can be avoided in this way.
And, accordingly, it will be easier to upgrade. Delete the changed directory and upload again.
There is a version and there is a hash sum of the current version of all application data (files + database).
At startup, both values are checked.
If there is a discrepancy, a synchronization operation is performed:
1. Detection of differences
2. Preparation of a list of changes relative to the current version of the user
3. Backup of the current version of the user
4. Downloading all necessary files to the user's device. (with the possibility of resuming when the connection is broken)
5. Making changes.
6. Checking the changes made (p. 1)
7. Deleting the backup copy (created in p. 3)
If any of the points is interrupted (the battery of the PC or smartphone has run out, etc.), it should always be possible to continue the update from the interrupted step.
Honestly, I have not come across this, but I would try to do this:
Let's say we release a new version - 2.46 . At the same time, we upload the full version to the server for a clean installation or for updating from very old versions, and make the nth number of patches 2.45to2.46 , 2.44to2.46 , 2.43to2.46 ... So, if the user is behind by several versions, it will simply download the minimum necessary difference between its version and the current one, but if the user has a very old version, he will download the entire client again.
Thus, the number of downloads for the user is minimized, and therefore the load on the server will also decrease.
The server reports the current version of the program, if there is no match, it resets the hash of all files of the new version of the program, then the client-side program bypasses each file recursively and compares the hash, if it does not match / does not find it, it downloads from the server. After the update is fully downloaded, it changes the software version.
Here you will not download anything extra unnecessarily, solve the problem of disconnected connections and solve the problem in cases of loss / deletion / substitution of files
The server sends a file that contains the date of the last change relative to the user's time zone.
The user checks the modification date of the files. And writes them to an array The
user sends an array of "mismatched dates" and the server responds with json with hashes for files
Then we check the hashes for these files (we messed with the time zone in a friend)
And if it has changed, we load (or give the server a list of them and it generates in response archive with modified files)
Patches
- Not effective
- Too complicated, fraught with errors
- Support and speed of patch release and testing will become more difficult
How to do it (simplified scheme) 1. Get
a
list of files and their hashes (all) from the server
(if the hash is not correct, we consider that the file does not exist)
3. Upload 1 packed file from the server (not an archive with all files, but one at a time)
4. Unpack the files, with replacement
5. Enjoy the updated version
You can not count the hash all the time, but store the hash value locally and if the date of the file has changed, then calculate the hash again.
This scheme is very simple, there are no patches, only those files that are needed are downloaded, you don’t even need to store the version number, because. file checking.
Get your git server up and running for binary releases and open source scripts since Microsoft hasn't spawned apt update in 20 years. In especially perverted cases, you can even give away part of the sources, and build stand-alone gcc on the client with the -arch=host optimization.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question