summaryrefslogtreecommitdiff
path: root/src/downloadmanager.cpp
diff options
context:
space:
mode:
authorJonathan Feenstra <26406078+JonathanFeenstra@users.noreply.github.com>2025-05-23 09:24:23 +0200
committerGitHub <noreply@github.com>2025-05-23 09:24:23 +0200
commit5d766e94a7a3b3fa861d57d3ad6ae619d98dd5d8 (patch)
treeab91e870302fec6c5ef8b0bbc90cda8e480ec368 /src/downloadmanager.cpp
parenta823d2aa88bd00d10370d5516c4426e8780435f7 (diff)
Mass Metadata Parsing: Prevent re-querying and manual prompts to enter missing data (#2135)
* Add a button to "Query Info" of every download in the list --------- Co-authored-by: Deewens <dudonadrien@gmail.com> Co-authored-by: KenJyn76 <liambonilla@gmail.com> Co-authored-by: Al <26797547+Al12rs@users.noreply.github.com>
Diffstat (limited to 'src/downloadmanager.cpp')
-rw-r--r--src/downloadmanager.cpp54
1 files changed, 48 insertions, 6 deletions
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp
index 7c02b17b..52eb8c8e 100644
--- a/src/downloadmanager.cpp
+++ b/src/downloadmanager.cpp
@@ -441,6 +441,36 @@ void DownloadManager::refreshList()
}
}
+void DownloadManager::queryDownloadListInfo()
+{
+ int incompleteCount = 0;
+ for (size_t i = 0; i < m_ActiveDownloads.size(); i++) {
+ if (isInfoIncomplete(i)) {
+ incompleteCount++;
+ }
+ }
+
+ if (incompleteCount <= 5 ||
+ QMessageBox::question(
+ m_ParentWidget, tr("Query Metadata"),
+ tr("There are %1 downloads with incomplete metadata.\n\n"
+ "Do you want to fetch all incomplete metadata?\n"
+ "API requests will be consumed, and Mod Organizer may stutter.")
+ .arg(incompleteCount),
+ QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
+ TimeThis tt("DownloadManager::queryDownloadListInfo()");
+ log::info("Querying metadata for every download with incomplete info...");
+ startDisableDirWatcher();
+ for (size_t i = 0; i < m_ActiveDownloads.size(); i++) {
+ if (isInfoIncomplete(i)) {
+ queryInfoMd5(i, false);
+ }
+ }
+ endDisableDirWatcher();
+ log::info("Metadata has been retrieved successfully!");
+ }
+}
+
bool DownloadManager::addDownload(const QStringList& URLs, QString gameName, int modID,
int fileID, const ModRepositoryFileInfo* fileInfo)
{
@@ -1054,10 +1084,10 @@ void DownloadManager::queryInfo(int index)
QString fileName = getFileName(index);
QString ignore;
NexusInterface::interpretNexusFileName(fileName, ignore, info->m_FileInfo->modID,
- true);
+ info->m_AskIfNotFound);
if (info->m_FileInfo->modID < 0) {
bool ok = false;
- int modId = QInputDialog::getInt(nullptr, tr("Please enter the nexus mod id"),
+ int modId = QInputDialog::getInt(nullptr, tr("Please enter the Nexus mod ID"),
tr("Mod ID:"), 1, 1,
std::numeric_limits<int>::max(), 1, &ok);
// careful now: while the dialog was displayed, events were processed.
@@ -1068,7 +1098,13 @@ void DownloadManager::queryInfo(int index)
}
}
- if (info->m_FileInfo->gameName.size() == 0) {
+ if (info->m_FileInfo->gameName.isEmpty()) {
+ if (!info->m_AskIfNotFound) {
+ // in case the info couldn't be retrieved from Nexus due to connection issues,
+ // don't create a meta file so you can query again after the issues are resolved.
+ return;
+ }
+
SelectionDialog selection(
tr("Please select the source game code for %1").arg(getFileName(index)));
@@ -1091,7 +1127,7 @@ void DownloadManager::queryInfo(int index)
setState(info, STATE_FETCHINGMODINFO);
}
-void DownloadManager::queryInfoMd5(int index)
+void DownloadManager::queryInfoMd5(int index, bool askIfNotFound)
{
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
reportError(tr("query: invalid download index %1").arg(index));
@@ -1148,8 +1184,9 @@ void DownloadManager::queryInfoMd5(int index)
progress.close();
downloadFile.close();
- info->m_Hash = hash.result();
- info->m_ReQueried = true;
+ info->m_Hash = hash.result();
+ info->m_ReQueried = true;
+ info->m_AskIfNotFound = askIfNotFound;
setState(info, STATE_FETCHINGMODINFO_MD5);
}
@@ -2133,6 +2170,11 @@ void DownloadManager::nxmRequestFailed(QString gameName, int modID, int fileID,
info->m_GamesToQuery.pop_front();
setState(info, STATE_FETCHINGMODINFO_MD5);
return;
+ } else if (errorCode == 404 && !info->m_AskIfNotFound) {
+ // prevent re-querying (only possible with repository = "Nexus")
+ info->m_FileInfo->repository = "";
+ setState(info, STATE_READY);
+ return;
} else {
info->m_State = STATE_READY;
queryInfo(index);