MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / executeTask

Method executeTask

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 11

enabledMethod · 0.80
internal_idMethod · 0.80
metadataMethod · 0.80
nextMethod · 0.80
refreshMethod · 0.45
containsMethod · 0.45
setStatusMethod · 0.45
setMetadataMethod · 0.45
removeMethod · 0.45
statusMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected