MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / executeTask

Method executeTask

launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp:55–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53{}
54
55void ModFolderLoadTask::executeTask()
56{
57 if (thread() != m_thread_to_spawn_into)
58 connect(this, &Task::finished, this->thread(), &QThread::quit);
59
60 if (m_is_indexed) {
61 // Read metadata first
62 getFromMetadata();
63 }
64
65 // Read JAR files that don't have metadata
66 m_mods_dir.refresh();
67 for (auto entry : m_mods_dir.entryInfoList()) {
68 auto filePath = entry.absoluteFilePath();
69 if (auto app = APPLICATION_DYN; app && app->checkQSavePath(filePath)) {
70 continue;
71 }
72 auto newFilePath = FS::getUniqueResourceName(filePath);
73 if (newFilePath != filePath) {
74 FS::move(filePath, newFilePath);
75 entry = QFileInfo(newFilePath);
76 }
77 Mod* mod(new Mod(entry));
78
79 if (mod->enabled()) {
80 if (m_result->mods.contains(mod->internal_id())) {
81 m_result->mods[mod->internal_id()]->setStatus(ModStatus::Installed);
82 // Delete the object we just created, since a valid one is already in the mods list.
83 delete mod;
84 } else {
85 m_result->mods[mod->internal_id()].reset(std::move(mod));
86 m_result->mods[mod->internal_id()]->setStatus(ModStatus::NoMetadata);
87 }
88 } else {
89 QString chopped_id = mod->internal_id().chopped(9);
90 if (m_result->mods.contains(chopped_id)) {
91 m_result->mods[mod->internal_id()].reset(std::move(mod));
92
93 auto metadata = m_result->mods[chopped_id]->metadata();
94 if (metadata) {
95 mod->setMetadata(*metadata);
96
97 m_result->mods[mod->internal_id()]->setStatus(ModStatus::Installed);
98 m_result->mods.remove(chopped_id);
99 }
100 } else {
101 m_result->mods[mod->internal_id()].reset(std::move(mod));
102 m_result->mods[mod->internal_id()]->setStatus(ModStatus::NoMetadata);
103 }
104 }
105 }
106
107 // Remove orphan metadata to prevent issues
108 // See https://github.com/PolyMC/PolyMC/issues/996
109 if (m_clean_orphan) {
110 QMutableMapIterator iter(m_result->mods);
111 while (iter.hasNext()) {
112 auto mod = iter.next().value();

Callers

nothing calls this directly

Calls 15

getUniqueResourceNameFunction · 0.85
moveFunction · 0.85
QFileInfoClass · 0.85
checkQSavePathMethod · 0.80
enabledMethod · 0.80
internal_idMethod · 0.80
metadataMethod · 0.80
valueMethod · 0.80
refreshMethod · 0.45
containsMethod · 0.45
setStatusMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected