fix: check for portable updater before running it (#6801)
Reviewed-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -54,6 +54,7 @@
|
||||
- Bugfix: Disable "Sort Tabs Alphabetically" action when notebook layout is locked. (#6710)
|
||||
- Bugfix: Fix highlight mentions not updating when username changes. (#6723, #6739)
|
||||
- Bugfix: Fixed Return and Enter being treated as different keys on Mac OS. (#6726)
|
||||
- Bugfix: Fixed portable updates not showing an error if the updater is not present. (#6801)
|
||||
- Dev: Nightly builds are now defined through a build flag rather than the Modes file. (#6798)
|
||||
- Dev: Update release documentation. (#6498)
|
||||
- Dev: Make code sanitizers opt in with the `CHATTERINO_SANITIZER_SUPPORT` CMake option. After that's enabled, use the `SANITIZE_*` flag to enable individual sanitizers. (#6493)
|
||||
|
||||
@@ -198,10 +198,19 @@ void Updates::installUpdates()
|
||||
file.flush();
|
||||
file.close();
|
||||
|
||||
QProcess::startDetached(
|
||||
combinePath(QCoreApplication::applicationDirPath(),
|
||||
"updater.1/ChatterinoUpdater.exe"),
|
||||
{filename, "restart"});
|
||||
auto updaterPath = Updates::portableUpdaterPath();
|
||||
if (!QFile::exists(updaterPath))
|
||||
{
|
||||
this->setStatus_(MissingPortableUpdater);
|
||||
return;
|
||||
}
|
||||
bool ok =
|
||||
QProcess::startDetached(updaterPath, {filename, "restart"});
|
||||
if (!ok)
|
||||
{
|
||||
this->setStatus_(RunUpdaterFailed);
|
||||
return;
|
||||
}
|
||||
|
||||
QApplication::exit(0);
|
||||
})
|
||||
@@ -399,6 +408,12 @@ Updates::Status Updates::getStatus() const
|
||||
return this->status_;
|
||||
}
|
||||
|
||||
QString Updates::portableUpdaterPath()
|
||||
{
|
||||
return combinePath(QCoreApplication::applicationDirPath(),
|
||||
"updater.1/ChatterinoUpdater.exe");
|
||||
}
|
||||
|
||||
bool Updates::shouldShowUpdateButton() const
|
||||
{
|
||||
switch (this->getStatus())
|
||||
@@ -422,6 +437,8 @@ bool Updates::isError() const
|
||||
case SearchFailed:
|
||||
case DownloadFailed:
|
||||
case WriteFileFailed:
|
||||
case MissingPortableUpdater:
|
||||
case RunUpdaterFailed:
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
||||
@@ -36,6 +36,8 @@ public:
|
||||
Downloading,
|
||||
DownloadFailed,
|
||||
WriteFileFailed,
|
||||
MissingPortableUpdater,
|
||||
RunUpdaterFailed,
|
||||
};
|
||||
|
||||
static bool isDowngradeOf(const QString &online, const QString ¤t);
|
||||
@@ -51,6 +53,8 @@ public:
|
||||
void installUpdates();
|
||||
Status getStatus() const;
|
||||
|
||||
static QString portableUpdaterPath();
|
||||
|
||||
bool shouldShowUpdateButton() const;
|
||||
bool isError() const;
|
||||
bool isDowngrade() const;
|
||||
|
||||
@@ -97,6 +97,18 @@ void UpdateDialog::updateStatusChanged(Updates::Status status)
|
||||
}
|
||||
break;
|
||||
|
||||
case Updates::MissingPortableUpdater: {
|
||||
this->ui_.label->setText("The portable updater (expected in " %
|
||||
Updates::portableUpdaterPath() %
|
||||
") was not found.");
|
||||
}
|
||||
break;
|
||||
|
||||
case Updates::RunUpdaterFailed: {
|
||||
this->ui_.label->setText("Failed to run the updater.");
|
||||
}
|
||||
break;
|
||||
|
||||
default:;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user