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: Disable "Sort Tabs Alphabetically" action when notebook layout is locked. (#6710)
|
||||||
- Bugfix: Fix highlight mentions not updating when username changes. (#6723, #6739)
|
- 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 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: Nightly builds are now defined through a build flag rather than the Modes file. (#6798)
|
||||||
- Dev: Update release documentation. (#6498)
|
- 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)
|
- 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.flush();
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
QProcess::startDetached(
|
auto updaterPath = Updates::portableUpdaterPath();
|
||||||
combinePath(QCoreApplication::applicationDirPath(),
|
if (!QFile::exists(updaterPath))
|
||||||
"updater.1/ChatterinoUpdater.exe"),
|
{
|
||||||
{filename, "restart"});
|
this->setStatus_(MissingPortableUpdater);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bool ok =
|
||||||
|
QProcess::startDetached(updaterPath, {filename, "restart"});
|
||||||
|
if (!ok)
|
||||||
|
{
|
||||||
|
this->setStatus_(RunUpdaterFailed);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QApplication::exit(0);
|
QApplication::exit(0);
|
||||||
})
|
})
|
||||||
@@ -399,6 +408,12 @@ Updates::Status Updates::getStatus() const
|
|||||||
return this->status_;
|
return this->status_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Updates::portableUpdaterPath()
|
||||||
|
{
|
||||||
|
return combinePath(QCoreApplication::applicationDirPath(),
|
||||||
|
"updater.1/ChatterinoUpdater.exe");
|
||||||
|
}
|
||||||
|
|
||||||
bool Updates::shouldShowUpdateButton() const
|
bool Updates::shouldShowUpdateButton() const
|
||||||
{
|
{
|
||||||
switch (this->getStatus())
|
switch (this->getStatus())
|
||||||
@@ -422,6 +437,8 @@ bool Updates::isError() const
|
|||||||
case SearchFailed:
|
case SearchFailed:
|
||||||
case DownloadFailed:
|
case DownloadFailed:
|
||||||
case WriteFileFailed:
|
case WriteFileFailed:
|
||||||
|
case MissingPortableUpdater:
|
||||||
|
case RunUpdaterFailed:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ public:
|
|||||||
Downloading,
|
Downloading,
|
||||||
DownloadFailed,
|
DownloadFailed,
|
||||||
WriteFileFailed,
|
WriteFileFailed,
|
||||||
|
MissingPortableUpdater,
|
||||||
|
RunUpdaterFailed,
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool isDowngradeOf(const QString &online, const QString ¤t);
|
static bool isDowngradeOf(const QString &online, const QString ¤t);
|
||||||
@@ -51,6 +53,8 @@ public:
|
|||||||
void installUpdates();
|
void installUpdates();
|
||||||
Status getStatus() const;
|
Status getStatus() const;
|
||||||
|
|
||||||
|
static QString portableUpdaterPath();
|
||||||
|
|
||||||
bool shouldShowUpdateButton() const;
|
bool shouldShowUpdateButton() const;
|
||||||
bool isError() const;
|
bool isError() const;
|
||||||
bool isDowngrade() const;
|
bool isDowngrade() const;
|
||||||
|
|||||||
@@ -97,6 +97,18 @@ void UpdateDialog::updateStatusChanged(Updates::Status status)
|
|||||||
}
|
}
|
||||||
break;
|
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:;
|
default:;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user