summaryrefslogtreecommitdiffstats
path: root/logic/updater
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-12-28 02:03:53 +0100
committerPetr Mrázek <peterix@gmail.com>2013-12-28 04:23:48 +0100
commit7652b3d64a63c587f520633364412345083210d4 (patch)
tree12d98c301aa931f20aee0875242bc762cf4d22d1 /logic/updater
parent30d4f5981d3220386bd320534048594fc364d0e9 (diff)
downloadMultiMC-7652b3d64a63c587f520633364412345083210d4.tar
MultiMC-7652b3d64a63c587f520633364412345083210d4.tar.gz
MultiMC-7652b3d64a63c587f520633364412345083210d4.tar.lz
MultiMC-7652b3d64a63c587f520633364412345083210d4.tar.xz
MultiMC-7652b3d64a63c587f520633364412345083210d4.zip
Various updater fixes
Updater tests for path utils The updater now doesn't use splitpath on Windows (fixes problems with Windows XP) Fix up paths for the OSX updater - should now install the updates into the right place Fix translations install path - translation isntall and deploy should be fixed
Diffstat (limited to 'logic/updater')
-rw-r--r--logic/updater/DownloadUpdateTask.cpp36
-rw-r--r--logic/updater/DownloadUpdateTask.h16
2 files changed, 46 insertions, 6 deletions
diff --git a/logic/updater/DownloadUpdateTask.cpp b/logic/updater/DownloadUpdateTask.cpp
index 057ca436..0b09ad2a 100644
--- a/logic/updater/DownloadUpdateTask.cpp
+++ b/logic/updater/DownloadUpdateTask.cpp
@@ -66,7 +66,7 @@ void DownloadUpdateTask::processChannels()
if (channel.id == channelId)
{
QLOG_INFO() << "Found matching channel.";
- m_cRepoUrl = preparePath(channel.url);
+ m_cRepoUrl = fixPathForTests(channel.url);
break;
}
}
@@ -207,8 +207,17 @@ bool DownloadUpdateTask::parseVersionInfo(const QByteArray &data, VersionFileLis
{
QJsonObject fileObj = fileValue.toObject();
+ QString file_path = fileObj.value("Path").toString();
+#ifdef Q_OS_MAC
+ // On OSX, the paths for the updater need to be fixed.
+ // basically, anything that isn't in the .app folder is ignored.
+ // everything else is changed so the code that processes the files actually finds
+ // them and puts the replacements in the right spots.
+ if(!fixPathForOSX(file_path))
+ continue;
+#endif
VersionFileEntry file{
- fileObj.value("Path").toString(), fileObj.value("Perms").toVariant().toInt(),
+ file_path , fileObj.value("Perms").toVariant().toInt(),
FileSourceList(), fileObj.value("MD5").toString(), };
QLOG_DEBUG() << "File" << file.path << "with perms" << file.mode;
@@ -221,12 +230,12 @@ bool DownloadUpdateTask::parseVersionInfo(const QByteArray &data, VersionFileLis
if (type == "http")
{
file.sources.append(
- FileSource("http", preparePath(sourceObj.value("Url").toString())));
+ FileSource("http", fixPathForTests(sourceObj.value("Url").toString())));
}
else if (type == "httpc")
{
file.sources.append(FileSource("httpc",
- preparePath(sourceObj.value("Url").toString()),
+ fixPathForTests(sourceObj.value("Url").toString()),
sourceObj.value("CompressionType").toString()));
}
else
@@ -491,7 +500,7 @@ bool DownloadUpdateTask::writeInstallScript(UpdateOperationList &opsList, QStrin
return true;
}
-QString DownloadUpdateTask::preparePath(const QString &path)
+QString DownloadUpdateTask::fixPathForTests(const QString &path)
{
if(path.startsWith("$PWD"))
{
@@ -502,6 +511,23 @@ QString DownloadUpdateTask::preparePath(const QString &path)
return path;
}
+bool DownloadUpdateTask::fixPathForOSX(QString &path)
+{
+ if(path.startsWith("MultiMC.app/"))
+ {
+ // remove the prefix and add a new, more appropriate one.
+ path.remove(0,12);
+ path = QString("../../") + path;
+ return true;
+ }
+ else
+ {
+ QLOG_ERROR() << "Update path not within .app: " << path;
+ return false;
+ }
+}
+
+
void DownloadUpdateTask::fileDownloadFinished()
{
emitSucceeded();
diff --git a/logic/updater/DownloadUpdateTask.h b/logic/updater/DownloadUpdateTask.h
index 79d73af3..d82b044f 100644
--- a/logic/updater/DownloadUpdateTask.h
+++ b/logic/updater/DownloadUpdateTask.h
@@ -198,7 +198,21 @@ protected:
* Filters paths
* Path of the format $PWD/path, it is converted to a file:///$PWD/ URL
*/
- static QString preparePath(const QString &path);
+ static QString fixPathForTests(const QString &path);
+
+ /*!
+ * Filters paths
+ * This fixes destination paths for OSX.
+ * The updater runs in MultiMC.app/Contents/MacOs by default
+ * The destination paths are such as this: MultiMC.app/blah/blah
+ *
+ * Therefore we chop off the 'MultiMC.app' prefix and prepend ../..
+ *
+ * Returns false if the path couldn't be fixed (is invalid)
+ *
+ * Has no effect on systems that aren't OSX
+ */
+ static bool fixPathForOSX(QString &path);
protected slots:
void vinfoDownloadFinished();