@@ -441,6 +441,36 @@ void DownloadManager::refreshList()
441441 }
442442}
443443
444+ void DownloadManager::queryDownloadListInfo ()
445+ {
446+ int incompleteCount = 0 ;
447+ for (size_t i = 0 ; i < m_ActiveDownloads.size (); i++) {
448+ if (isInfoIncomplete (i)) {
449+ incompleteCount++;
450+ }
451+ }
452+
453+ if (incompleteCount <= 5 ||
454+ QMessageBox::question (
455+ m_ParentWidget, tr (" Query Metadata" ),
456+ tr (" There are %1 downloads with incomplete metadata.\n\n "
457+ " Do you want to fetch all incomplete metadata?\n "
458+ " API requests will be consumed, and Mod Organizer may stutter." )
459+ .arg (incompleteCount),
460+ QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
461+ TimeThis tt (" DownloadManager::queryDownloadListInfo()" );
462+ log::info (" Querying metadata for every download with incomplete info..." );
463+ startDisableDirWatcher ();
464+ for (size_t i = 0 ; i < m_ActiveDownloads.size (); i++) {
465+ if (isInfoIncomplete (i)) {
466+ queryInfoMd5 (i, false );
467+ }
468+ }
469+ endDisableDirWatcher ();
470+ log::info (" Metadata has been retrieved successfully!" );
471+ }
472+ }
473+
444474bool DownloadManager::addDownload (const QStringList& URLs, QString gameName, int modID,
445475 int fileID, const ModRepositoryFileInfo* fileInfo)
446476{
@@ -1054,10 +1084,10 @@ void DownloadManager::queryInfo(int index)
10541084 QString fileName = getFileName (index);
10551085 QString ignore;
10561086 NexusInterface::interpretNexusFileName (fileName, ignore, info->m_FileInfo ->modID ,
1057- true );
1087+ info-> m_AskIfNotFound );
10581088 if (info->m_FileInfo ->modID < 0 ) {
10591089 bool ok = false ;
1060- int modId = QInputDialog::getInt (nullptr , tr (" Please enter the nexus mod id " ),
1090+ int modId = QInputDialog::getInt (nullptr , tr (" Please enter the Nexus mod ID " ),
10611091 tr (" Mod ID:" ), 1 , 1 ,
10621092 std::numeric_limits<int >::max (), 1 , &ok);
10631093 // careful now: while the dialog was displayed, events were processed.
@@ -1068,7 +1098,13 @@ void DownloadManager::queryInfo(int index)
10681098 }
10691099 }
10701100
1071- if (info->m_FileInfo ->gameName .size () == 0 ) {
1101+ if (info->m_FileInfo ->gameName .isEmpty ()) {
1102+ if (!info->m_AskIfNotFound ) {
1103+ // in case the info couldn't be retrieved from Nexus due to connection issues,
1104+ // don't create a meta file so you can query again after the issues are resolved.
1105+ return ;
1106+ }
1107+
10721108 SelectionDialog selection (
10731109 tr (" Please select the source game code for %1" ).arg (getFileName (index)));
10741110
@@ -1091,7 +1127,7 @@ void DownloadManager::queryInfo(int index)
10911127 setState (info, STATE_FETCHINGMODINFO);
10921128}
10931129
1094- void DownloadManager::queryInfoMd5 (int index)
1130+ void DownloadManager::queryInfoMd5 (int index, bool askIfNotFound )
10951131{
10961132 if ((index < 0 ) || (index >= m_ActiveDownloads.size ())) {
10971133 reportError (tr (" query: invalid download index %1" ).arg (index));
@@ -1148,8 +1184,9 @@ void DownloadManager::queryInfoMd5(int index)
11481184 progress.close ();
11491185 downloadFile.close ();
11501186
1151- info->m_Hash = hash.result ();
1152- info->m_ReQueried = true ;
1187+ info->m_Hash = hash.result ();
1188+ info->m_ReQueried = true ;
1189+ info->m_AskIfNotFound = askIfNotFound;
11531190 setState (info, STATE_FETCHINGMODINFO_MD5);
11541191}
11551192
@@ -2133,6 +2170,11 @@ void DownloadManager::nxmRequestFailed(QString gameName, int modID, int fileID,
21332170 info->m_GamesToQuery .pop_front ();
21342171 setState (info, STATE_FETCHINGMODINFO_MD5);
21352172 return ;
2173+ } else if (errorCode == 404 && !info->m_AskIfNotFound ) {
2174+ // prevent re-querying (only possible with repository = "Nexus")
2175+ info->m_FileInfo ->repository = " " ;
2176+ setState (info, STATE_READY);
2177+ return ;
21362178 } else {
21372179 info->m_State = STATE_READY;
21382180 queryInfo (index);
0 commit comments