summaryrefslogtreecommitdiffstats
path: root/MultiMC.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-01-05 13:17:42 +0100
committerPetr Mrázek <peterix@gmail.com>2014-01-05 13:17:42 +0100
commit613c01dab5222a99fa642a466ce37ade53f1c072 (patch)
tree76e7397ed67679d168a40b36035d898b406b1430 /MultiMC.cpp
parent76f58eb42ccc2c19f6952cbae501c17c06c3671b (diff)
downloadMultiMC-613c01dab5222a99fa642a466ce37ade53f1c072.tar
MultiMC-613c01dab5222a99fa642a466ce37ade53f1c072.tar.gz
MultiMC-613c01dab5222a99fa642a466ce37ade53f1c072.tar.lz
MultiMC-613c01dab5222a99fa642a466ce37ade53f1c072.tar.xz
MultiMC-613c01dab5222a99fa642a466ce37ade53f1c072.zip
Some more updater fixes
Paths were wrong - still used work directory instead of root
Diffstat (limited to 'MultiMC.cpp')
-rw-r--r--MultiMC.cpp37
1 files changed, 24 insertions, 13 deletions
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<JavaVersionList> 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)