1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Better checks before applying update

Check that each file was downloaded and that the size matches. We don't check the signatures inside qTox so as not to freeze the GUI during startup. The updater will check the signatures anyway

We now try to restart update downloads if we detect that it was interrupted
This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2015-01-05 09:35:55 +01:00
parent 8813d6e4ca
commit 56e9f6f1be
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
2 changed files with 18 additions and 4 deletions

View File

@ -370,7 +370,7 @@ bool AutoUpdater::isLocalUpdateReady()
if (!updateDir.exists())
return false;
// Check that we have a flist and that every file on the diff exists
// Check that we have a flist and generate a diff
QFile updateFlistFile(updateDirStr+"flist");
if (!updateFlistFile.open(QIODevice::ReadOnly))
return false;
@ -380,9 +380,23 @@ bool AutoUpdater::isLocalUpdateReady()
QList<UpdateFileMeta> updateFlist = parseFlist(updateFlistData);
QList<UpdateFileMeta> diff = genUpdateDiff(updateFlist);
// If the update wasn't downloaded correctly, redownload it
// We don't check signatures to not block qTox too long, the updater will do it anyway
for (UpdateFileMeta fileMeta : diff)
{
if (!QFile::exists(updateDirStr+fileMeta.installpath))
{
QtConcurrent::run(&AutoUpdater::downloadUpdate);
return false;
}
QFile f(updateDirStr+fileMeta.installpath);
if (f.size() != (int64_t)fileMeta.size)
{
QtConcurrent::run(&AutoUpdater::downloadUpdate);
return false;
}
}
return true;
}

View File

@ -78,9 +78,9 @@ public:
/// Will try to download an update, if successful returns true and qTox will apply it after a restart
/// Will try to follow qTox's proxy settings, may block and processEvents
static bool downloadUpdate();
/// Returns true if an update is downloaded and ready to be installed
/// If so, call installLocalUpdate. If not, call downloadUpdate.
/// This only checks that we downloaded an update and didn't stop in the middle, not that every file is still valid
/// Returns true if an update is downloaded and ready to be installed,
/// if so, call installLocalUpdate.
/// If an update was partially downloaded, the function will resume asynchronously and return false
static bool isLocalUpdateReady();
/// Launches the qTox updater to try to install the local update and exits immediately
/// Will not check that the update actually exists, use isLocalUpdateReady first for that