mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
fixed the updating mechanism
This commit is contained in:
parent
00d538b368
commit
8f34a0af59
|
@ -42,7 +42,7 @@ void UpdateManager::installUpdates()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
//#ifdef Q_OS_WIN
|
||||||
QMessageBox *box = new QMessageBox(QMessageBox::Information, "Chatterino Update",
|
QMessageBox *box = new QMessageBox(QMessageBox::Information, "Chatterino Update",
|
||||||
"Chatterino is downloading the update "
|
"Chatterino is downloading the update "
|
||||||
"in the background and will run the "
|
"in the background and will run the "
|
||||||
|
@ -55,10 +55,12 @@ void UpdateManager::installUpdates()
|
||||||
req.onError([this](int) -> bool {
|
req.onError([this](int) -> bool {
|
||||||
this->setStatus_(DownloadFailed);
|
this->setStatus_(DownloadFailed);
|
||||||
|
|
||||||
|
util::postToThread([] {
|
||||||
QMessageBox *box = new QMessageBox(QMessageBox::Information, "Chatterino Update",
|
QMessageBox *box = new QMessageBox(QMessageBox::Information, "Chatterino Update",
|
||||||
"Failed while trying to download the update.");
|
"Failed while trying to download the update.");
|
||||||
box->setAttribute(Qt::WA_DeleteOnClose);
|
box->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
box->show();
|
box->show();
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
@ -66,24 +68,28 @@ void UpdateManager::installUpdates()
|
||||||
auto filename = util::combinePath(getApp()->paths->miscDirectory, "update.zip");
|
auto filename = util::combinePath(getApp()->paths->miscDirectory, "update.zip");
|
||||||
|
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
|
file.open(QIODevice::Truncate | QIODevice::WriteOnly);
|
||||||
|
|
||||||
if (file.write(object) == -1) {
|
if (file.write(object) == -1) {
|
||||||
this->setStatus_(WriteFileFailed);
|
this->setStatus_(WriteFileFailed);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QProcess::startDetached("./updater.1/ChatterinoUpdater.exe", {filename, "restart"});
|
QProcess::startDetached(util::combinePath(QCoreApplication::applicationDirPath(),
|
||||||
|
"updater.1/ChatterinoUpdater.exe"),
|
||||||
|
{filename, "restart"});
|
||||||
|
|
||||||
QApplication::exit(0);
|
QApplication::exit(0);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
this->setStatus_(Downloading);
|
this->setStatus_(Downloading);
|
||||||
req.execute();
|
req.execute();
|
||||||
#endif
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateManager::checkForUpdates()
|
void UpdateManager::checkForUpdates()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WIN
|
//#ifdef Q_OS_WIN
|
||||||
QString url = "https://notitia.chatterino.com/version/chatterino/" CHATTERINO_OS "/stable";
|
QString url = "https://notitia.chatterino.com/version/chatterino/" CHATTERINO_OS "/stable";
|
||||||
|
|
||||||
util::NetworkRequest req(url);
|
util::NetworkRequest req(url);
|
||||||
|
@ -120,7 +126,7 @@ void UpdateManager::checkForUpdates()
|
||||||
box->setAttribute(Qt::WA_DeleteOnClose);
|
box->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
box->show();
|
box->show();
|
||||||
if (box->exec() == QMessageBox::Yes) {
|
if (box->exec() == QMessageBox::Yes) {
|
||||||
this->installUpdates();
|
util::postToThread([this] { this->installUpdates(); });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this->setStatus_(NoUpdateAvailable);
|
this->setStatus_(NoUpdateAvailable);
|
||||||
|
@ -128,7 +134,7 @@ void UpdateManager::checkForUpdates()
|
||||||
});
|
});
|
||||||
this->setStatus_(Searching);
|
this->setStatus_(Searching);
|
||||||
req.execute();
|
req.execute();
|
||||||
#endif
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateManager::UpdateStatus UpdateManager::getStatus() const
|
UpdateManager::UpdateStatus UpdateManager::getStatus() const
|
||||||
|
|
Loading…
Reference in a new issue