MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / installDownload

Method installDownload

src/organizercore.cpp:838–881  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

836}
837
838ModInfo::Ptr OrganizerCore::installDownload(int index, int priority)
839{
840 ScopedDisableDirWatcher scopedDirwatcher(&m_DownloadManager);
841
842 try {
843 QString fileName = m_DownloadManager.getFilePath(index);
844 QString gameName = m_DownloadManager.getGameName(index);
845 int modID = m_DownloadManager.getModID(index);
846 int fileID = m_DownloadManager.getFileInfo(index)->fileID;
847 ModInfo::Ptr currentMod = nullptr;
848 GuessedValue<QString> modName;
849
850 // see if there already are mods with the specified mod id
851 if (modID > 0) {
852 std::vector<ModInfo::Ptr> modInfo = ModInfo::getByModID(gameName, modID);
853 for (auto iter = modInfo.begin(); iter != modInfo.end(); ++iter) {
854 std::vector<ModInfo::EFlag> flags = (*iter)->getFlags();
855 if (std::find(flags.begin(), flags.end(), ModInfo::FLAG_BACKUP) ==
856 flags.end()) {
857 modName.update((*iter)->name(), GUESS_PRESET);
858 currentMod = *iter;
859 (*iter)->saveMeta();
860 }
861 }
862 }
863
864 const auto [modIndex, modInfo] =
865 doInstall(fileName, modName, currentMod, priority, false);
866
867 if (modInfo != nullptr) {
868 modInfo->addInstalledFile(modID, fileID);
869 m_DownloadManager.markInstalled(index);
870 if (settings().interface().hideDownloadsAfterInstallation()) {
871 m_DownloadManager.removeDownload(index, false);
872 }
873 }
874
875 return modInfo;
876 } catch (const std::exception& e) {
877 reportError(QString(e.what()));
878 }
879
880 return nullptr;
881}
882
883ModInfo::Ptr OrganizerCore::installArchive(const QString& archivePath, int priority,
884 bool reinstallation, ModInfo::Ptr currentMod,

Callers 1

setupMethod · 0.80

Calls 15

QStringClass · 0.85
getFilePathMethod · 0.80
getGameNameMethod · 0.80
getModIDMethod · 0.80
markInstalledMethod · 0.80
removeDownloadMethod · 0.80
getFileInfoMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
getFlagsMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected