diff options
author | Petr Mrázek <peterix@gmail.com> | 2014-07-10 01:26:45 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2014-07-10 01:26:45 +0200 |
commit | 40c238442f154b05d8d4ce29e0a6bc0d2c6afdf4 (patch) | |
tree | 4fd129dd20c45ce54a2e2ad25617ba918cdc2687 /logic | |
parent | ff06489fed081ed34af63c6ffbdd61e6f917dd3a (diff) | |
download | MultiMC-40c238442f154b05d8d4ce29e0a6bc0d2c6afdf4.tar MultiMC-40c238442f154b05d8d4ce29e0a6bc0d2c6afdf4.tar.gz MultiMC-40c238442f154b05d8d4ce29e0a6bc0d2c6afdf4.tar.lz MultiMC-40c238442f154b05d8d4ce29e0a6bc0d2c6afdf4.tar.xz MultiMC-40c238442f154b05d8d4ce29e0a6bc0d2c6afdf4.zip |
Fix #354, make jar mods and patch files in general more resilient.
Diffstat (limited to 'logic')
-rw-r--r-- | logic/minecraft/InstanceVersion.cpp | 7 | ||||
-rw-r--r-- | logic/minecraft/VersionBuilder.cpp | 8 |
2 files changed, 12 insertions, 3 deletions
diff --git a/logic/minecraft/InstanceVersion.cpp b/logic/minecraft/InstanceVersion.cpp index e71609e6..addbcc84 100644 --- a/logic/minecraft/InstanceVersion.cpp +++ b/logic/minecraft/InstanceVersion.cpp @@ -85,7 +85,8 @@ bool InstanceVersion::remove(const int index) { return false; } - if(!QFile::remove(VersionPatches.at(index)->getPatchFilename())) + auto toDelete = VersionPatches.at(index)->getPatchFilename(); + if(!QFile::remove(toDelete)) return false; beginRemoveRows(QModelIndex(), index, index); VersionPatches.removeAt(index); @@ -504,8 +505,10 @@ void InstanceVersion::installJarModByFilename(QString filepath) f->name = target_name; f->fileId = target_id; f->order = getFreeOrderNumber(); + QString patchFileName = PathCombine(patchDir, target_id + ".json"); + f->filename = patchFileName; - QFile file(PathCombine(patchDir, target_id + ".json")); + QFile file(patchFileName); if (!file.open(QFile::WriteOnly)) { QLOG_ERROR() << "Error opening" << file.fileName() diff --git a/logic/minecraft/VersionBuilder.cpp b/logic/minecraft/VersionBuilder.cpp index 66e7d327..fea0c8d1 100644 --- a/logic/minecraft/VersionBuilder.cpp +++ b/logic/minecraft/VersionBuilder.cpp @@ -111,8 +111,14 @@ void VersionBuilder::readInstancePatches() continue; // parse the file QString filename = patches.absoluteFilePath(id + ".json"); + QFileInfo finfo(filename); + if(!finfo.exists()) + { + QLOG_INFO() << "Patch file " << filename << " was deleted by external means..."; + continue; + } QLOG_INFO() << "Reading" << filename << "by user order"; - auto file = parseJsonFile(QFileInfo(filename), false); + auto file = parseJsonFile(finfo, false); // sanity check. prevent tampering with files. if (file->fileId != id) { |