diff options
Diffstat (limited to 'src/downloadmanager.cpp')
| -rw-r--r-- | src/downloadmanager.cpp | 58 |
1 files changed, 34 insertions, 24 deletions
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 8b644b8c..7b416d50 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -432,6 +432,13 @@ bool DownloadManager::addDownload(QNetworkReply *reply, const QStringList &URLs, } } + // baseName could be a URL at this point so strip out the URL query + int queryIndex = baseName.indexOf("?"); + if (queryIndex >= 0) + { + baseName.truncate(queryIndex); + } + startDisableDirWatcher(); newDownload->setName(getDownloadFileName(baseName), false); endDisableDirWatcher(); @@ -951,13 +958,20 @@ void DownloadManager::queryInfo(int index) SelectionDialog selection(tr("Please select the source game code for %1").arg(getFileName(index))); std::vector<std::pair<QString, QString>> choices = m_NexusInterface->getGameChoices(m_ManagedGame); - for (auto choice : choices) { - selection.addChoice(choice.first, choice.second, choice.first); + if (choices.size() == 1) + { + info->m_FileInfo->gameName = choices[0].first; } - if (selection.exec() == QDialog::Accepted) { - info->m_FileInfo->gameName = selection.getChoiceData().toString(); - } else { - info->m_FileInfo->gameName = m_ManagedGame->gameShortName(); + else { + for (auto choice : choices) { + selection.addChoice(choice.first, choice.second, choice.first); + } + if (selection.exec() == QDialog::Accepted) { + info->m_FileInfo->gameName = selection.getChoiceData().toString(); + } + else { + info->m_FileInfo->gameName = m_ManagedGame->gameShortName(); + } } } info->m_ReQueried = true; @@ -1823,8 +1837,14 @@ void DownloadManager::nxmFileInfoFromMd5Available(QString gameName, QVariant use auto fileDetails = results["file_details"].toMap(); if (fileDetails["file_name"].toString().compare(info->m_FileName, Qt::CaseInsensitive) == 0) { - chosenIdx = i; - break; + if (chosenIdx < 0) { + chosenIdx = i; //intentional to not break in order to check other results + } + else { + log::debug("Multiple files with same name found during MD5 search."); + chosenIdx = -1; + break; + } } } } @@ -1839,7 +1859,7 @@ void DownloadManager::nxmFileInfoFromMd5Available(QString gameName, QVariant use if (chosenIdx < 0) { chosenIdx = i; //intentional to not break in order to check other results } else { - log::debug("Multiple active files found during MD5 search. Defaulting to time stamps..."); + log::debug("Multiple active files found during MD5 search."); chosenIdx = -1; break; } @@ -1847,24 +1867,14 @@ void DownloadManager::nxmFileInfoFromMd5Available(QString gameName, QVariant use } } - //Look for the most recent one + //Unable to determine the correct mod / file. Revert to the old method if (chosenIdx < 0) { - int mostRecentTime = INT_MIN; - for (int i = 0; i < resultlist.count(); i++) { - auto results = resultlist[i].toMap(); - auto fileDetails = results["file_details"].toMap(); - - int fileTime = fileDetails["uploaded_timestamp"].toInt(); - if (fileTime > mostRecentTime) { - chosenIdx = i; - mostRecentTime = fileTime; - } - } + //don't use the normal state set function as we don't want to create a meta file + info->m_State = DownloadManager::STATE_READY; + queryInfo(m_ActiveDownloads.indexOf(info)); + return; } - //If nothing is preferred, just use the first one - if (chosenIdx < 0) chosenIdx = 0; - auto results = resultlist[chosenIdx].toMap(); auto fileDetails = results["file_details"].toMap(); auto modDetails = results["mod"].toMap(); |
