Commit 421346ac authored by Leander Schulten's avatar Leander Schulten

Updater: Fix crash when no update is available (e.g. when the job is currently running)

parent 20964cdd
Pipeline #288100 passed with stage
in 8 minutes and 43 seconds
......@@ -42,11 +42,16 @@ void Updater::checkForUpdate(){
request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
auto response = http->get(request);
QObject::connect(response, &QNetworkReply::finished, [this, response]() {
response->deleteLater();
if (response->attribute(QNetworkRequest::HttpStatusCodeAttribute) != 200) {
state = NoUpdateAvailible;
emit stateChanged();
return;
}
QFile version(QDir::tempPath() + QStringLiteral("/version.zip"));
version.open(QFile::WriteOnly);
version.write(response->readAll());
version.close();
response->deleteLater();
auto watcher = new QFutureWatcher<bool>;
connect(watcher, &QFutureWatcher<bool>::finished, [this, version = QFileInfo(version), watcher]() {
......@@ -115,6 +120,11 @@ void Updater::update(){
qDebug() << response->atEnd();
response->deleteLater();
deploy->close();
if (response->attribute(QNetworkRequest::HttpStatusCodeAttribute) != 200) {
state = DownloadUpdateFailed;
emit stateChanged();
return;
}
state = UpdaterState::UnzippingUpdate;
emit stateChanged();
auto watcher = new QFutureWatcher<bool>;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment