Browse Source

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
pull/982/head
Tux3 / Mlkj / !Lev.uXFMLA 11 years ago
parent
commit
56e9f6f1be
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
  1. 16
      src/autoupdate.cpp
  2. 6
      src/autoupdate.h

16
src/autoupdate.cpp

@ -370,7 +370,7 @@ bool AutoUpdater::isLocalUpdateReady() @@ -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() @@ -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;
}

6
src/autoupdate.h

@ -78,9 +78,9 @@ public: @@ -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

Loading…
Cancel
Save