I think you misunderstood Klaue's suggestion. In this case, he's suggesting no change to the PXML, only a change to the repository specification. The idea is that, for each application listed in the JSON repo, you would add an extra field, "md5", with the value of the MD5 hash you calculated, preferably in hexadecimal. Then, my client downloads the JSON file, including all the MD5 hashes; when the client downloads a PND, it calculates the hash of the PND and compares it to the hash listed in the JSON. That way the client knows that the PND was downloaded properly without errors.
Not exactly, but close. I seem to have a stunning ability to not make myself clear
Yes, the hash calculation would be server side, but there's no need to do it client-side (except for checking the integrity of the downloaded file, but with todays internet.. when was the last time you had to redownload a file because your download failed? The last time that happened to me must be 1998 or so
)
I'll try to make an example. Suppose you have a PND, called "You can't get ye flask", and you have 3 repositories
Those repositories have the following data of that PND:
repo1: id=klaue.youcantgetyeflask hash=d41d8cd98f00b204e9800998ecf8427e
repo2: id=klaue.youcantgetyeflask hash=dd1310245728cc97d7458bd562815d59
repo3: id=klaue.youcantgetyeflask hash=d41d8cd98f00b204e9800998ecf8427e
As you can see, the hash of repo2 differs from the rest. Now assume that repo1 was the one with the highest priority in the client (probably the official, if there will ever be one, or the largest of the existing ones). So what your program would do is, from the start:
1. Download all JSONs of all repositories.
2. Build a list of aviable PNDs
3. (Do other stuff, like checking which ones are allready installed)
4. The user searches for "You can't get ye flask"
5. You iterate trough your repositories, in descending priority order, until you find the game
6. You found it, in our example case, right in the first repository
7. Now you search the remaining repositories for the same ID - you'll find them in repo2 and repo3
8. You check the hashes, taking the hash of the highest priority repository (of the ones in which you found the file, in this case repo1) as the master
9. You'll notice that repo3 has the same hash, but repo2 has a different one, so you discard repo2 because it's probably a counterfeit entry or at least a repackaged one, but it's better to be save than sorry.
10. If your user wants to download the game, you'll download it either from repo1 or repo3, but NOT from repo2.
11. Because you have, in this case, 2 servers to download the file from, you can do some client side load balancing, for example if the user downloads another PND, you can parallelly (sp?) download that PND off repo1 and the youcantgetyeflask one from repo3. Or you can download the first part of the PND from repo1 and the second part, at the same time, from repo3 and then stick the parts together again.
The reason for that is that, in most cases, the clients download speed will be better than the servers upload speed, so the client will be faster if it downloads from multiple sources at the same time. It would also be lighter on the servers.
of course, you can do steps 5-9 inside step 2, but that doesn't matter
now clear what I meant? I don't really know how to say this any other way, sorry
EDIT: maybe to clarify: The version of the PND that is deemed the valid one is the one on the highest-priotitry repository. The reason for this is that people would probably configure the client to make the official repository (if there will be one) or the largest repository the highest priority. Now, If I made a PND, I would maybe upload it to various repositories, but I would sure as hgell upload it at least to the official or largest one.
If someone would build a malicious PND with the same ID as another one, he couldn't upload it to that repository because the valid version is allready on there (and of course no repository would allow a random user to overwrite an entry by another user), so he would have to upload it to a smaller repository.
With my proposed safety measure, using the hash of the highest priority repository would ensure that a bogus version on some of the smaller repositories wouldn't get through.
(Note that I assume that there will be multiple repositories in the future - the whole repository spec wouldn't make much sense if there weren't)