UpdateManager#tryUpdate does not check if downloaded update jar is up to date
kristofbolyai opened this issue ยท 6 comments
File updateFile = getUpdateFile();
if (updateFile.exists()) {
future.complete(UpdateResult.UPDATE_PENDING);
return future;
}
As seen, there is no check if the update file is the latest one. In fact, there is no check the update files works/is intact. A simple hash check could resolve this, and other problems related to updating, like corrupted update file making the feature not work.
Is the hash available from Athena?
Yes, we use it later in the method. And we can easily hash the local file too.
It will be trivial to fix after #826 is merged.
It made me realize, though, that I do not verify md5 correctness after download. That is perhaps something that should be added to the NetManager.
Of the downloaded file. If we have a hash associated with a file, we check the file in the cache, and if there is a mis-match, we delete the file and download it from the specified url. But since that URL is supposed to render a file with the given md5, we could also use it to verify that the download were successful. I did not think of that use case, only of the md5 as a way to validate the cache.
Then of course comes the question -- what do we do if the md5 is not correct? If we make a mistake in setting the md5 sum, we could get stuck in an eternal loop where we download a file, sees it does not match the supposedly correct md5, ditches it due to the assumption that it must have been a borked download, and tries again, over and over.
Of the downloaded file. If we have a hash associated with a file, we check the file in the cache, and if there is a mis-match, we delete the file and download it from the specified url. But since that URL is supposed to render a file with the given md5, we could also use it to verify that the download were successful. I did not think of that use case, only of the md5 as a way to validate the cache.
Then of course comes the question -- what do we do if the md5 is not correct? If we make a mistake in setting the md5 sum, we could get stuck in an eternal loop where we download a file, sees it does not match the supposedly correct md5, ditches it due to the assumption that it must have been a borked download, and tries again, over and over.
I see. Maybe we don't have to worry about this atm.