| 836 | } |
| 837 | |
| 838 | ModInfo::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 | |
| 883 | ModInfo::Ptr OrganizerCore::installArchive(const QString& archivePath, int priority, |
| 884 | bool reinstallation, ModInfo::Ptr currentMod, |
no test coverage detected