summaryrefslogtreecommitdiffstats
path: root/logic/updater
diff options
context:
space:
mode:
Diffstat (limited to 'logic/updater')
-rw-r--r--logic/updater/DownloadUpdateTask.cpp50
-rw-r--r--logic/updater/DownloadUpdateTask.h4
-rw-r--r--logic/updater/UpdateChecker.cpp1
3 files changed, 29 insertions, 26 deletions
diff --git a/logic/updater/DownloadUpdateTask.cpp b/logic/updater/DownloadUpdateTask.cpp
index 029286dd..e16d2aa2 100644
--- a/logic/updater/DownloadUpdateTask.cpp
+++ b/logic/updater/DownloadUpdateTask.cpp
@@ -290,12 +290,11 @@ DownloadUpdateTask::processFileLists(NetJob *job,
// delete anything in the current one version's list that isn't in the new version's list.
for (VersionFileEntry entry : currentVersion)
{
- QFileInfo toDelete(entry.path);
+ QFileInfo toDelete(PathCombine(MMC->root(), entry.path));
if (!toDelete.exists())
{
QLOG_ERROR() << "Expected file " << toDelete.absoluteFilePath()
<< " doesn't exist!";
- QLOG_ERROR() << "CWD: " << QDir::currentPath();
}
bool keep = false;
@@ -314,7 +313,6 @@ DownloadUpdateTask::processFileLists(NetJob *job,
// If the loop reaches the end and we didn't find a match, delete the file.
if (!keep)
{
- QFileInfo toDelete(entry.path);
if (toDelete.exists())
ops.append(UpdateOperation::DeleteOp(entry.path));
}
@@ -326,8 +324,9 @@ DownloadUpdateTask::processFileLists(NetJob *job,
// TODO: Let's not MD5sum a ton of files on the GUI thread. We should probably find a
// way to do this in the background.
QString fileMD5;
- QFile entryFile(entry.path);
- QFileInfo entryInfo(entry.path);
+ QString realEntryPath = PathCombine(MMC->root(), entry.path);
+ QFile entryFile(realEntryPath);
+ QFileInfo entryInfo(realEntryPath);
bool needs_upgrade = false;
if (!entryFile.exists())
@@ -339,49 +338,52 @@ DownloadUpdateTask::processFileLists(NetJob *job,
bool pass = true;
if (!entryInfo.isReadable())
{
- QLOG_ERROR() << "File " << entry.path << " is not readable.";
+ QLOG_ERROR() << "File " << realEntryPath << " is not readable.";
pass = false;
}
if (!entryInfo.isWritable())
{
- QLOG_ERROR() << "File " << entry.path << " is not writable.";
+ QLOG_ERROR() << "File " << realEntryPath << " is not writable.";
pass = false;
}
if (!entryFile.open(QFile::ReadOnly))
{
- QLOG_ERROR() << "File " << entry.path << " cannot be opened for reading.";
+ QLOG_ERROR() << "File " << realEntryPath << " cannot be opened for reading.";
pass = false;
}
if (!pass)
{
- QLOG_ERROR() << "CWD: " << QDir::currentPath();
+ QLOG_ERROR() << "ROOT: " << MMC->root();
ops.clear();
return false;
}
}
- QCryptographicHash hash(QCryptographicHash::Md5);
- auto foo = entryFile.readAll();
-
- hash.addData(foo);
- fileMD5 = hash.result().toHex();
- if ((fileMD5 != entry.md5))
+ if(!needs_upgrade)
{
- QLOG_DEBUG() << "MD5Sum does not match!";
- QLOG_DEBUG() << "Expected:'" << entry.md5 << "'";
- QLOG_DEBUG() << "Got: '" << fileMD5 << "'";
- needs_upgrade = true;
+ QCryptographicHash hash(QCryptographicHash::Md5);
+ auto foo = entryFile.readAll();
+
+ hash.addData(foo);
+ fileMD5 = hash.result().toHex();
+ if ((fileMD5 != entry.md5))
+ {
+ QLOG_DEBUG() << "MD5Sum does not match!";
+ QLOG_DEBUG() << "Expected:'" << entry.md5 << "'";
+ QLOG_DEBUG() << "Got: '" << fileMD5 << "'";
+ needs_upgrade = true;
+ }
}
// skip file. it doesn't need an upgrade.
if (!needs_upgrade)
{
- QLOG_DEBUG() << "File" << entry.path << " does not need updating.";
+ QLOG_DEBUG() << "File" << realEntryPath << " does not need updating.";
continue;
}
// yep. this file actually needs an upgrade. PROCEED.
- QLOG_DEBUG() << "Found file" << entry.path << " that needs updating.";
+ QLOG_DEBUG() << "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");
@@ -402,12 +404,17 @@ DownloadUpdateTask::processFileLists(NetJob *job,
if (isUpdater)
{
+#ifdef MultiMC_UPDATER_FORCE_LOCAL
+ QLOG_DEBUG() << "Skipping updater download and using local version.";
+#else
auto cache_entry = MMC->metacache()->resolveEntry("root", entry.path);
QLOG_DEBUG() << "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);
+#endif
}
else
{
@@ -514,7 +521,6 @@ bool DownloadUpdateTask::fixPathForOSX(QString &path)
{
// remove the prefix and add a new, more appropriate one.
path.remove(0, 12);
- path = QString("../../") + path;
return true;
}
else
diff --git a/logic/updater/DownloadUpdateTask.h b/logic/updater/DownloadUpdateTask.h
index b1d14846..4feab871 100644
--- a/logic/updater/DownloadUpdateTask.h
+++ b/logic/updater/DownloadUpdateTask.h
@@ -206,11 +206,9 @@ protected:
* 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 ../..
+ * Therefore we chop off the 'MultiMC.app' prefix
*
* 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);
diff --git a/logic/updater/UpdateChecker.cpp b/logic/updater/UpdateChecker.cpp
index acf74f40..489e7769 100644
--- a/logic/updater/UpdateChecker.cpp
+++ b/logic/updater/UpdateChecker.cpp
@@ -17,7 +17,6 @@
#include "MultiMC.h"
-#include "config.h"
#include "logger/QsLog.h"
#include <QJsonObject>