From 613c01dab5222a99fa642a466ce37ade53f1c072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 5 Jan 2014 13:17:42 +0100 Subject: Some more updater fixes Paths were wrong - still used work directory instead of root --- MultiMC.cpp | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'MultiMC.cpp') diff --git a/MultiMC.cpp b/MultiMC.cpp index 1b915542..2bc77e0f 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -261,6 +261,7 @@ MultiMC::MultiMC(int &argc, char **argv, const QString &data_dir_override) return; } */ + connect(this, SIGNAL(aboutToQuit()), SLOT(onExit())); m_status = MultiMC::Initialized; } @@ -510,8 +511,21 @@ std::shared_ptr MultiMC::javalist() return m_javalist; } -void MultiMC::installUpdates(const QString &updateFilesDir, bool restartOnFinish) +void MultiMC::installUpdates(const QString updateFilesDir, UpdateFlags flags) { + // if we are going to update on exit, save the params now + if(flags & OnExit) + { + m_updateOnExitPath = updateFilesDir; + m_updateOnExitFlags = flags & ~OnExit; + return; + } + // otherwise if there already were some params for on exit update, clear them and continue + else if(m_updateOnExitPath.size()) + { + m_updateOnExitFlags = None; + m_updateOnExitPath.clear(); + } QLOG_INFO() << "Installing updates."; #ifdef WINDOWS QString finishCmd = MMC->applicationFilePath(); @@ -533,16 +547,15 @@ void MultiMC::installUpdates(const QString &updateFilesDir, bool restartOnFinish args << "--package-dir" << updateFilesDir; args << "--script" << PathCombine(updateFilesDir, "file_list.xml"); args << "--wait" << QString::number(MMC->applicationPid()); -#ifdef MultiMC_UPDATER_DRY_RUN - args << "--dry-run"; -#endif - if (restartOnFinish) + if(flags & DryRun) + args << "--dry-run"; + if (flags & RestartOnFinish) args << "--finish-cmd" << finishCmd; QLOG_INFO() << "Running updater with command" << updaterBinary << args.join(" "); QFile::setPermissions(updaterBinary, (QFileDevice::Permission)0x7755); - if (!QProcess::startDetached(updaterBinary, args)) + if (!QProcess::startDetached(updaterBinary, args/*, root()*/)) { QLOG_ERROR() << "Failed to start the updater process!"; return; @@ -552,14 +565,12 @@ void MultiMC::installUpdates(const QString &updateFilesDir, bool restartOnFinish MMC->quit(); } -void MultiMC::setUpdateOnExit(const QString &updateFilesDir) +void MultiMC::onExit() { - m_updateOnExitPath = updateFilesDir; -} - -QString MultiMC::getExitUpdatePath() const -{ - return m_updateOnExitPath; + if(m_updateOnExitPath.size()) + { + installUpdates(m_updateOnExitPath, m_updateOnExitFlags); + } } bool MultiMC::openJsonEditor(const QString &filename) -- cgit v1.2.3