summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Bessent <lost.dragonist@gmail.com>2020-01-10 16:51:41 -0700
committerChris Bessent <lost.dragonist@gmail.com>2020-01-10 17:18:45 -0700
commit08410deece846839b3e4e52e45d2d7b2264689e0 (patch)
treed913cc5704ca7a535ce609cd213527a0a084bb2b /src
parent07e5ce1e0e0c398d018e69eff2f4654b60db4a0d (diff)
Use the old query info logic when MD5 query is ambiguous
An author accidentally uploaded a mod's files to a different mod. This resulted in querying info finding the wrong mod/file.
Diffstat (limited to 'src')
-rw-r--r--src/downloadmanager.cpp32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp
index adfbc84d..fa2c959c 100644
--- a/src/downloadmanager.cpp
+++ b/src/downloadmanager.cpp
@@ -1823,8 +1823,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 +1845,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 +1853,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();