| 63 | } |
| 64 | |
| 65 | bool processFileLists |
| 66 | ( |
| 67 | const VersionFileList ¤tVersion, |
| 68 | const VersionFileList &newVersion, |
| 69 | const QString &rootPath, |
| 70 | const QString &tempPath, |
| 71 | NetJob::Ptr job, |
| 72 | OperationList &ops |
| 73 | ) |
| 74 | { |
| 75 | // First, if we've loaded the current version's file list, we need to iterate through it and |
| 76 | // delete anything in the current one version's list that isn't in the new version's list. |
| 77 | for (VersionFileEntry entry : currentVersion) |
| 78 | { |
| 79 | QFileInfo toDelete(FS::PathCombine(rootPath, entry.path)); |
| 80 | if (!toDelete.exists()) |
| 81 | { |
| 82 | qCritical() << "Expected file " << toDelete.absoluteFilePath() |
| 83 | << " doesn't exist!"; |
| 84 | } |
| 85 | bool keep = false; |
| 86 | |
| 87 | // |
| 88 | for (VersionFileEntry newEntry : newVersion) |
| 89 | { |
| 90 | if (newEntry.path == entry.path) |
| 91 | { |
| 92 | qDebug() << "Not deleting" << entry.path |
| 93 | << "because it is still present in the new version."; |
| 94 | keep = true; |
| 95 | break; |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | // If the loop reaches the end and we didn't find a match, delete the file. |
| 100 | if (!keep) |
| 101 | { |
| 102 | if (toDelete.exists()) |
| 103 | ops.append(Operation::DeleteOp(entry.path)); |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | // Next, check each file in MultiMC's folder and see if we need to update them. |
| 108 | for (VersionFileEntry entry : newVersion) |
| 109 | { |
| 110 | // TODO: Let's not MD5sum a ton of files on the GUI thread. We should probably find a |
| 111 | // way to do this in the background. |
| 112 | QString fileMD5; |
| 113 | QString realEntryPath = FS::PathCombine(rootPath, entry.path); |
| 114 | QFile entryFile(realEntryPath); |
| 115 | QFileInfo entryInfo(realEntryPath); |
| 116 | |
| 117 | bool needs_upgrade = false; |
| 118 | if (!entryFile.exists()) |
| 119 | { |
| 120 | needs_upgrade = true; |
| 121 | } |
| 122 | else |