MCPcopy Create free account
hub / github.com/MultiMC/Launcher / processFileLists

Function processFileLists

launcher/updater/GoUpdate.cpp:65–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65bool processFileLists
66(
67 const VersionFileList &currentVersion,
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

Callers 2

test_processFileListsMethod · 0.85

Calls 10

PathCombineFunction · 0.85
QStringClass · 0.85
existsMethod · 0.80
appendMethod · 0.80
openMethod · 0.80
addNetActionMethod · 0.80
clearMethod · 0.45
resultMethod · 0.45
replaceMethod · 0.45
addValidatorMethod · 0.45

Tested by 1

test_processFileListsMethod · 0.68