fix(updater): force asInvoker
for updater on windows
- use `__COMPAT_LAYER` env var in windows to bypass Installer Detection and run as a normal user anyway - set up updater directly after main windows is created - check update locks before main window Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
parent
00f75e2d54
commit
a01a48793c
@ -959,23 +959,6 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||
|
||||
updateCapabilities();
|
||||
|
||||
if (createSetupWizard()) {
|
||||
return;
|
||||
}
|
||||
|
||||
performMainStartupAction();
|
||||
|
||||
// initialize the updater
|
||||
if (updaterEnabled()) {
|
||||
qDebug() << "Initializing updater";
|
||||
#ifdef Q_OS_MAC
|
||||
m_updater.reset(new MacSparkleUpdater());
|
||||
#else
|
||||
m_updater.reset(new PrismExternalUpdater(m_mainWindow, applicationDirPath(), m_dataPath));
|
||||
#endif
|
||||
qDebug() << "<> Updater started.";
|
||||
}
|
||||
|
||||
// check update locks
|
||||
{
|
||||
auto update_log_path = FS::PathCombine(m_dataPath, "logs", "prism_launcher_update.log");
|
||||
@ -1076,6 +1059,12 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||
FS::deletePath(update_success_marker.absoluteFilePath());
|
||||
}
|
||||
}
|
||||
|
||||
if (createSetupWizard()) {
|
||||
return;
|
||||
}
|
||||
|
||||
performMainStartupAction();
|
||||
}
|
||||
|
||||
bool Application::createSetupWizard()
|
||||
@ -1219,6 +1208,18 @@ void Application::performMainStartupAction()
|
||||
showMainWindow(false);
|
||||
qDebug() << "<> Main window shown.";
|
||||
}
|
||||
|
||||
// initialize the updater
|
||||
if (updaterEnabled()) {
|
||||
qDebug() << "Initializing updater";
|
||||
#ifdef Q_OS_MAC
|
||||
m_updater.reset(new MacSparkleUpdater());
|
||||
#else
|
||||
m_updater.reset(new PrismExternalUpdater(m_mainWindow, applicationDirPath(), m_dataPath));
|
||||
#endif
|
||||
qDebug() << "<> Updater started.";
|
||||
}
|
||||
|
||||
if (!m_zipsToImport.isEmpty()) {
|
||||
qDebug() << "<> Importing from zip:" << m_zipsToImport;
|
||||
m_mainWindow->processURLs(m_zipsToImport);
|
||||
|
@ -96,6 +96,10 @@ void PrismExternalUpdater::checkForUpdates()
|
||||
auto exe_name = QStringLiteral("%1_updater").arg(BuildConfig.LAUNCHER_APP_BINARY_NAME);
|
||||
#if defined Q_OS_WIN32
|
||||
exe_name.append(".exe");
|
||||
|
||||
auto env = QProcessEnvironment::systemEnvironment();
|
||||
env.insert("__COMPAT_LAYER", "RUNASINVOKER");
|
||||
proc.setProcessEnvironment(env);
|
||||
#endif
|
||||
|
||||
QStringList args = { "--check-only", "--dir", priv->dataDir.absolutePath(), "--debug" };
|
||||
@ -328,6 +332,10 @@ void PrismExternalUpdater::performUpdate(const QString& version_tag)
|
||||
auto exe_name = QStringLiteral("%1_updater").arg(BuildConfig.LAUNCHER_APP_BINARY_NAME);
|
||||
#if defined Q_OS_WIN32
|
||||
exe_name.append(".exe");
|
||||
|
||||
auto env = QProcessEnvironment::systemEnvironment();
|
||||
env.insert("__COMPAT_LAYER", "RUNASINVOKER");
|
||||
proc.setProcessEnvironment(env);
|
||||
#endif
|
||||
|
||||
QStringList args = { "--dir", priv->dataDir.absolutePath(), "--install-version", version_tag };
|
||||
|
@ -704,7 +704,12 @@ void PrismUpdaterApp::moveAndFinishUpdate(QDir target)
|
||||
auto app_exe_name = BuildConfig.LAUNCHER_APP_BINARY_NAME;
|
||||
#if defined Q_OS_WIN32
|
||||
app_exe_name.append(".exe");
|
||||
|
||||
auto env = QProcessEnvironment::systemEnvironment();
|
||||
env.insert("__COMPAT_LAYER", "RUNASINVOKER");
|
||||
proc.setProcessEnvironment(env);
|
||||
#endif
|
||||
|
||||
auto app_exe_path = target.absoluteFilePath(app_exe_name);
|
||||
proc.startDetached(app_exe_path);
|
||||
|
||||
@ -990,6 +995,11 @@ void PrismUpdaterApp::performInstall(QFileInfo file)
|
||||
} else {
|
||||
logUpdate(tr("Running installer file at %1").arg(file.absoluteFilePath()));
|
||||
QProcess proc = QProcess();
|
||||
#if defined Q_OS_WIN
|
||||
auto env = QProcessEnvironment::systemEnvironment();
|
||||
env.insert("__COMPAT_LAYER", "RUNASINVOKER");
|
||||
proc.setProcessEnvironment(env);
|
||||
#endif
|
||||
proc.setProgram(file.absoluteFilePath());
|
||||
bool result = proc.startDetached();
|
||||
logUpdate(tr("Process start result: %1").arg(result ? tr("yes") : tr("no")));
|
||||
@ -1005,13 +1015,20 @@ void PrismUpdaterApp::unpackAndInstall(QFileInfo archive)
|
||||
if (auto loc = unpackArchive(archive)) {
|
||||
auto marker_file_path = loc.value().absoluteFilePath(".prism_launcher_updater_unpack.marker");
|
||||
FS::write(marker_file_path, applicationDirPath().toUtf8());
|
||||
|
||||
QProcess proc = QProcess();
|
||||
|
||||
auto exe_name = QStringLiteral("%1_updater").arg(BuildConfig.LAUNCHER_APP_BINARY_NAME);
|
||||
#if defined Q_OS_WIN32
|
||||
exe_name.append(".exe");
|
||||
|
||||
auto env = QProcessEnvironment::systemEnvironment();
|
||||
env.insert("__COMPAT_LAYER", "RUNASINVOKER");
|
||||
proc.setProcessEnvironment(env);
|
||||
#endif
|
||||
|
||||
auto new_updater_path = loc.value().absoluteFilePath(exe_name);
|
||||
logUpdate(tr("Starting new updater at '%1'").arg(new_updater_path));
|
||||
QProcess proc = QProcess();
|
||||
if (!proc.startDetached(new_updater_path, { "-d", m_dataPath }, loc.value().absolutePath())) {
|
||||
logUpdate(tr("Failed to launch '%1' %2").arg(new_updater_path).arg(proc.errorString()));
|
||||
return exit(10);
|
||||
|
Loading…
Reference in New Issue
Block a user