summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--application/BuildConfig.cpp.in3
-rw-r--r--application/BuildConfig.h6
-rw-r--r--application/CMakeLists.txt16
-rw-r--r--application/MainWindow.cpp17
-rw-r--r--application/MainWindow.h2
-rw-r--r--application/MultiMC.cpp46
-rw-r--r--application/MultiMC.h15
-rw-r--r--application/dialogs/UpdateDialog.cpp6
-rw-r--r--application/dialogs/UpdateDialog.h2
-rw-r--r--application/dialogs/UpdateDialog.ui12
-rw-r--r--logic/updater/DownloadTask.cpp7
-rw-r--r--logic/updater/DownloadTask.h2
-rw-r--r--logic/updater/GoUpdate.cpp38
-rw-r--r--logic/updater/GoUpdate.h17
-rw-r--r--tests/tst_DownloadTask.cpp8
15 files changed, 28 insertions, 169 deletions
diff --git a/application/BuildConfig.cpp.in b/application/BuildConfig.cpp.in
index 04cfbf05..16920cb2 100644
--- a/application/BuildConfig.cpp.in
+++ b/application/BuildConfig.cpp.in
@@ -17,9 +17,6 @@ Config::Config()
NOTIFICATION_URL = "@MultiMC_NOTIFICATION_URL@";
FULL_VERSION_STR = "@MultiMC_VERSION_MAJOR@.@MultiMC_VERSION_MINOR@.@MultiMC_VERSION_BUILD@";
- UPDATER_DRY_RUN = @MultiMC_UPDATER_DRY_RUN_value@;
- UPDATER_FORCE_LOCAL = @MultiMC_UPDATER_FORCE_LOCAL_value@;
-
GIT_COMMIT = "@MultiMC_GIT_COMMIT@";
VERSION_STR = "@MultiMC_VERSION_STRING@";
NEWS_RSS_URL = "@MultiMC_NEWS_RSS_URL@";
diff --git a/application/BuildConfig.h b/application/BuildConfig.h
index 60aefeb4..8a6a76b5 100644
--- a/application/BuildConfig.h
+++ b/application/BuildConfig.h
@@ -35,12 +35,6 @@ public:
/// Used for matching notifications
QString FULL_VERSION_STR;
- /// enabled for updater dry run
- bool UPDATER_DRY_RUN;
-
- /// enabled for updater dry run
- bool UPDATER_FORCE_LOCAL;
-
/// The commit hash of this build
QString GIT_COMMIT;
diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt
index d3962819..a9ee1da6 100644
--- a/application/CMakeLists.txt
+++ b/application/CMakeLists.txt
@@ -75,22 +75,6 @@ if(MultiMC_UPDATER)
message(STATUS "Updater is enabled. Channel list URL: ${MultiMC_CHANLIST_URL}")
endif()
-#### Updater-related build config options ####
-option(MultiMC_UPDATER_DRY_RUN "Enable updater dry-run mode -- for updater development." OFF)
-option(MultiMC_UPDATER_FORCE_LOCAL "Do not download updated updater -- for updater development." OFF)
-
-if(MultiMC_UPDATER_DRY_RUN)
- set(MultiMC_UPDATER_DRY_RUN_value "true")
-else()
- set(MultiMC_UPDATER_DRY_RUN_value "false")
-endif()
-
-if(MultiMC_UPDATER_FORCE_LOCAL)
- set(MultiMC_UPDATER_FORCE_LOCAL_value "true")
-else()
- set(MultiMC_UPDATER_FORCE_LOCAL_value "false")
-endif()
-
######## Configure header ########
configure_file("${PROJECT_SOURCE_DIR}/BuildConfig.cpp.in" "${PROJECT_BINARY_DIR}/BuildConfig.cpp")
diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp
index 99c94bf8..933c4dbc 100644
--- a/application/MainWindow.cpp
+++ b/application/MainWindow.cpp
@@ -933,9 +933,6 @@ void MainWindow::updateAvailable(GoUpdate::Status status)
case UPDATE_NOW:
downloadUpdates(status);
break;
- case UPDATE_ONEXIT:
- downloadUpdates(status, true);
- break;
}
}
@@ -985,13 +982,9 @@ void MainWindow::notificationsChanged()
MMC->settings()->set("ShownNotifications", intListToString(shownNotifications));
}
-void MainWindow::downloadUpdates(GoUpdate::Status status, bool installOnExit)
+void MainWindow::downloadUpdates(GoUpdate::Status status)
{
qDebug() << "Downloading updates.";
- // TODO: If the user chooses to update on exit, we should download updates in the
- // background.
- // Doing so is a bit complicated, because we'd have to make sure it finished downloading
- // before actually exiting MultiMC.
ProgressDialog updateDlg(this);
status.rootPath = MMC->rootPath;
@@ -999,13 +992,7 @@ void MainWindow::downloadUpdates(GoUpdate::Status status, bool installOnExit)
// If the task succeeds, install the updates.
if (updateDlg.exec(&updateTask))
{
- UpdateFlags baseFlags = None;
- if (BuildConfig.UPDATER_DRY_RUN)
- baseFlags |= DryRun;
- if (installOnExit)
- MMC->installUpdates(updateTask.updateFilesDir(), baseFlags | OnExit);
- else
- MMC->installUpdates(updateTask.updateFilesDir(), baseFlags | RestartOnFinish);
+ MMC->installUpdates(updateTask.updateFilesDir());
}
else
{
diff --git a/application/MainWindow.h b/application/MainWindow.h
index 97111e04..33a5a4ed 100644
--- a/application/MainWindow.h
+++ b/application/MainWindow.h
@@ -177,7 +177,7 @@ slots:
/*!
* Runs the DownloadTask and installs updates.
*/
- void downloadUpdates(GoUpdate::Status status, bool installOnExit = false);
+ void downloadUpdates(GoUpdate::Status status);
protected:
bool eventFilter(QObject *obj, QEvent *ev);
diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp
index 2c6b387c..67b50b40 100644
--- a/application/MultiMC.cpp
+++ b/application/MultiMC.cpp
@@ -583,61 +583,27 @@ std::shared_ptr<JavaVersionList> MultiMC::javalist()
return m_javalist;
}
-void MultiMC::installUpdates(const QString updateFilesDir, UpdateFlags flags)
+void MultiMC::installUpdates(const QString updateFilesDir)
{
- // 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();
- }
qDebug() << "Installing updates.";
#ifdef WINDOWS
QString finishCmd = applicationFilePath();
- QString updaterBinary = PathCombine(applicationDirPath(), "updater.exe");
#elif LINUX
QString finishCmd = PathCombine(root(), "MultiMC");
- QString updaterBinary = PathCombine(applicationDirPath(), "updater");
#elif OSX
QString finishCmd = applicationFilePath();
- QString updaterBinary = PathCombine(applicationDirPath(), "updater");
#else
#error Unsupported operating system.
#endif
QStringList args;
- // ./updater --install-dir $INSTALL_DIR --package-dir $UPDATEFILES_DIR --script
- // $UPDATEFILES_DIR/file_list.xml --wait $PID --mode main
args << "--install-dir" << root();
args << "--package-dir" << updateFilesDir;
args << "--script" << PathCombine(updateFilesDir, "file_list.xml");
args << "--wait" << QString::number(applicationPid());
- if (flags & DryRun)
- args << "--dry-run";
- if (flags & RestartOnFinish)
- {
- args << "--finish-cmd" << finishCmd;
- args << "--finish-dir" << dataPath;
- }
- qDebug() << "Running updater with command" << updaterBinary << args.join(" ");
- QFile::setPermissions(updaterBinary, (QFileDevice::Permission)0x7755);
-
- if (!QProcess::startDetached(updaterBinary, args /*, root()*/))
- {
- qCritical() << "Failed to start the updater process!";
- return;
- }
-
- ENV.destroy();
- // Now that we've started the updater, quit MultiMC.
- quit();
+ args << "--finish-cmd" << finishCmd;
+ args << "--finish-dir" << dataPath;
+ qDebug() << "Running updater with args" << args.join(" ");
}
void MultiMC::setIconTheme(const QString& name)
@@ -657,10 +623,6 @@ void MultiMC::onExit()
{
m_instances->saveGroupList();
}
- if (m_updateOnExitPath.size())
- {
- installUpdates(m_updateOnExitPath, m_updateOnExitFlags);
- }
ENV.destroy();
if(logFile)
{
diff --git a/application/MultiMC.h b/application/MultiMC.h
index e4a54115..f815b8e4 100644
--- a/application/MultiMC.h
+++ b/application/MultiMC.h
@@ -29,16 +29,6 @@ class TranslationDownloader;
#endif
#define MMC (static_cast<MultiMC *>(QCoreApplication::instance()))
-enum UpdateFlag
-{
- None = 0x0,
- RestartOnFinish = 0x1,
- DryRun = 0x2,
- OnExit = 0x4
-};
-Q_DECLARE_FLAGS(UpdateFlags, UpdateFlag);
-Q_DECLARE_OPERATORS_FOR_FLAGS(UpdateFlags);
-
class MultiMC : public QApplication
{
// friends for the purpose of limiting access to deprecated stuff
@@ -115,7 +105,7 @@ public:
}
// APPLICATION ONLY
- void installUpdates(const QString updateFilesDir, UpdateFlags flags = None);
+ void installUpdates(const QString updateFilesDir);
/*!
* Opens a json file using either a system default editor, or, if note empty, the editor
@@ -173,9 +163,6 @@ private:
QMap<QString, std::shared_ptr<BaseProfilerFactory>> m_profilers;
QMap<QString, std::shared_ptr<BaseDetachedToolFactory>> m_tools;
- QString m_updateOnExitPath;
- UpdateFlags m_updateOnExitFlags = None;
-
QString rootPath;
QString staticDataPath;
QString dataPath;
diff --git a/application/dialogs/UpdateDialog.cpp b/application/dialogs/UpdateDialog.cpp
index d8f5d8ac..4240e3d5 100644
--- a/application/dialogs/UpdateDialog.cpp
+++ b/application/dialogs/UpdateDialog.cpp
@@ -21,7 +21,6 @@ UpdateDialog::UpdateDialog(bool hasUpdate, QWidget *parent) : QDialog(parent), u
{
ui->label->setText(tr("No %1 updates found. You are running the latest version.").arg(channel));
ui->btnUpdateNow->setDisabled(true);
- ui->btnUpdateOnExit->setDisabled(true);
}
loadChangelog();
}
@@ -129,8 +128,3 @@ void UpdateDialog::on_btnUpdateNow_clicked()
{
done(UPDATE_NOW);
}
-
-void UpdateDialog::on_btnUpdateOnExit_clicked()
-{
- done(UPDATE_ONEXIT);
-}
diff --git a/application/dialogs/UpdateDialog.h b/application/dialogs/UpdateDialog.h
index b92c7473..5237df5c 100644
--- a/application/dialogs/UpdateDialog.h
+++ b/application/dialogs/UpdateDialog.h
@@ -28,7 +28,6 @@ enum UpdateAction
{
UPDATE_LATER = QDialog::Rejected,
UPDATE_NOW = QDialog::Accepted,
- UPDATE_ONEXIT = 2
};
class UpdateDialog : public QDialog
@@ -43,7 +42,6 @@ private:
Ui::UpdateDialog *ui;
public slots:
void on_btnUpdateNow_clicked();
- void on_btnUpdateOnExit_clicked();
void on_btnUpdateLater_clicked();
/// Starts loading the changelog
diff --git a/application/dialogs/UpdateDialog.ui b/application/dialogs/UpdateDialog.ui
index 06f4f086..cbe1ef74 100644
--- a/application/dialogs/UpdateDialog.ui
+++ b/application/dialogs/UpdateDialog.ui
@@ -46,8 +46,8 @@
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
-&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Bitstream Vera Sans'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
-&lt;p align=&quot;center&quot; style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:22pt;&quot;&gt;Loading changelog...&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Oxygen-Sans'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p align=&quot;center&quot; style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Bitstream Vera Sans'; font-size:22pt;&quot;&gt;Loading changelog...&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
@@ -70,13 +70,6 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item>
- <widget class="QPushButton" name="btnUpdateOnExit">
- <property name="text">
- <string>Update after MultiMC closes</string>
- </property>
- </widget>
- </item>
- <item>
<widget class="QPushButton" name="btnUpdateLater">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@@ -96,7 +89,6 @@ p, li { white-space: pre-wrap; }
<tabstops>
<tabstop>changelogBrowser</tabstop>
<tabstop>btnUpdateNow</tabstop>
- <tabstop>btnUpdateOnExit</tabstop>
<tabstop>btnUpdateLater</tabstop>
</tabstops>
<resources>
diff --git a/logic/updater/DownloadTask.cpp b/logic/updater/DownloadTask.cpp
index f19607a5..352f1f0d 100644
--- a/logic/updater/DownloadTask.cpp
+++ b/logic/updater/DownloadTask.cpp
@@ -35,11 +35,6 @@ DownloadTask::DownloadTask(Status status, QObject *parent)
m_updateFilesDir.setAutoRemove(false);
}
-void DownloadTask::setUseLocalUpdater(bool useLocal)
-{
- m_keepLocalUpdater = useLocal;
-}
-
void DownloadTask::executeTask()
{
loadVersionInfo();
@@ -130,7 +125,7 @@ void DownloadTask::processDownloadedVersionInfo()
NetJobPtr netJob (new NetJob("Update Files"));
// fill netJob and operationList
- if (!processFileLists(m_currentVersionFileList, m_newVersionFileList, m_status.rootPath, m_updateFilesDir.path(), netJob, operationList, m_keepLocalUpdater))
+ if (!processFileLists(m_currentVersionFileList, m_newVersionFileList, m_status.rootPath, m_updateFilesDir.path(), netJob, operationList))
{
emitFailed(tr("Failed to process update lists..."));
return;
diff --git a/logic/updater/DownloadTask.h b/logic/updater/DownloadTask.h
index 182e76d6..197aa3e6 100644
--- a/logic/updater/DownloadTask.h
+++ b/logic/updater/DownloadTask.h
@@ -61,8 +61,6 @@ protected:
Status m_status;
- bool m_keepLocalUpdater;
-
/*!
* Temporary directory to store update files in.
* This will be set to not auto delete. Task will fail if this fails to be created.
diff --git a/logic/updater/GoUpdate.cpp b/logic/updater/GoUpdate.cpp
index 974f5e2b..d85f00d6 100644
--- a/logic/updater/GoUpdate.cpp
+++ b/logic/updater/GoUpdate.cpp
@@ -73,8 +73,7 @@ bool processFileLists
const QString &rootPath,
const QString &tempPath,
NetJobPtr job,
- OperationList &ops,
- bool useLocalUpdater
+ OperationList &ops
)
{
// First, if we've loaded the current version's file list, we need to iterate through it and
@@ -175,9 +174,6 @@ bool processFileLists
// yep. this file actually needs an upgrade. PROCEED.
qDebug() << "Found file" << realEntryPath << " that needs updating.";
- // if it's the updater we want to treat it separately
- bool isUpdater = entry.path.endsWith("updater") || entry.path.endsWith("updater.exe");
-
// Go through the sources list and find one to use.
// TODO: Make a NetAction that takes a source list and tries each of them until one
// works. For now, we'll just use the first http one.
@@ -192,32 +188,12 @@ bool processFileLists
// path with slashes replaced by underscores.
QString dlPath = PathCombine(tempPath, QString(entry.path).replace("/", "_"));
- if (isUpdater)
- {
- if(useLocalUpdater)
- {
- qDebug() << "Skipping updater download and using local version.";
- }
- else
- {
- auto cache_entry = ENV.metacache()->resolveEntry("root", entry.path);
- qDebug() << "Updater will be in " << cache_entry->getFullPath();
- // force check.
- cache_entry->stale = true;
-
- auto download = CacheDownload::make(QUrl(source.url), cache_entry);
- job->addNetAction(download);
- }
- }
- else
- {
- // We need to download the file to the updatefiles folder and add a task
- // to copy it to its install path.
- auto download = MD5EtagDownload::make(source.url, dlPath);
- download->m_expected_md5 = entry.md5;
- job->addNetAction(download);
- ops.append(Operation::CopyOp(dlPath, entry.path, entry.mode));
- }
+ // We need to download the file to the updatefiles folder and add a task
+ // to copy it to its install path.
+ auto download = MD5EtagDownload::make(source.url, dlPath);
+ download->m_expected_md5 = entry.md5;
+ job->addNetAction(download);
+ ops.append(Operation::CopyOp(dlPath, entry.path, entry.mode));
}
}
return true;
diff --git a/logic/updater/GoUpdate.h b/logic/updater/GoUpdate.h
index c58fd1eb..941c4e3a 100644
--- a/logic/updater/GoUpdate.h
+++ b/logic/updater/GoUpdate.h
@@ -66,10 +66,14 @@ typedef QList<VersionFileEntry> VersionFileList;
*/
struct Operation
{
- static Operation CopyOp(QString fsource, QString fdest, int fmode=0644) { return Operation{OP_COPY, fsource, fdest, fmode}; }
- static Operation MoveOp(QString fsource, QString fdest, int fmode=0644) { return Operation{OP_MOVE, fsource, fdest, fmode}; }
- static Operation DeleteOp(QString file) { return Operation{OP_DELETE, file, "", 0644}; }
- static Operation ChmodOp(QString file, int fmode) { return Operation{OP_CHMOD, file, "", fmode}; }
+ static Operation CopyOp(QString fsource, QString fdest, int fmode=0644)
+ {
+ return Operation{OP_COPY, fsource, fdest, fmode};
+ }
+ static Operation DeleteOp(QString file)
+ {
+ return Operation{OP_DELETE, file, "", 0644};
+ }
// FIXME: for some types, some of the other fields are irrelevant!
bool operator==(const Operation &u2) const
@@ -82,8 +86,6 @@ struct Operation
{
OP_COPY,
OP_DELETE,
- OP_MOVE,
- OP_CHMOD,
} type;
//! The file to operate on. If this is a DELETE or CHMOD operation, this is the file that will be modified.
@@ -118,8 +120,7 @@ bool processFileLists
const QString &rootPath,
const QString &tempPath,
NetJobPtr job,
- OperationList &ops,
- bool useLocalUpdater
+ OperationList &ops
);
/*!
diff --git a/tests/tst_DownloadTask.cpp b/tests/tst_DownloadTask.cpp
index 9482b666..289aa195 100644
--- a/tests/tst_DownloadTask.cpp
+++ b/tests/tst_DownloadTask.cpp
@@ -46,12 +46,6 @@ QDebug operator<<(QDebug dbg, const Operation::Type &t)
case Operation::OP_DELETE:
dbg << "OP_DELETE";
break;
- case Operation::OP_MOVE:
- dbg << "OP_MOVE";
- break;
- case Operation::OP_CHMOD:
- dbg << "OP_CHMOD";
- break;
}
return dbg.maybeSpace();
}
@@ -199,7 +193,7 @@ slots:
OperationList operations;
- processFileLists(currentVersion, newVersion, QCoreApplication::applicationDirPath(), tempFolder, new NetJob("Dummy"), operations, false);
+ processFileLists(currentVersion, newVersion, QCoreApplication::applicationDirPath(), tempFolder, new NetJob("Dummy"), operations);
qDebug() << (operations == expectedOperations);
qDebug() << operations;
qDebug() << expectedOperations;