@@ -442,50 +442,32 @@ void DownloadManager::refreshList()
442
442
443
443
void DownloadManager::queryDownloadListInfo ()
444
444
{
445
- TimeThis tt (" DownloadManager::queryDownloadListInfos()" );
446
-
447
- log ::info (" Retrieving data from every download (if possible)..." );
448
-
449
- int incompleteInfos = 0 ;
450
-
451
- // Just go through all active downloads to query infos
445
+ int incompleteCount = 0 ;
452
446
for (size_t i = 0 ; i < m_ActiveDownloads.size (); i++) {
453
447
if (isInfoIncomplete (i)) {
454
- incompleteInfos ++;
448
+ incompleteCount ++;
455
449
}
456
450
}
457
451
458
- if (incompleteInfos <= 5 ) {
459
- // Fetch metadata for incomplete download infos
452
+ if (incompleteCount <= 5 ||
453
+ QMessageBox::question (
454
+ m_ParentWidget, tr (" Query Metadata" ),
455
+ tr (" There are %1 downloads with incomplete metadata.\n\n "
456
+ " Do you want to fetch all incomplete metadata?\n "
457
+ " API requests will be consumed, and Mod Organizer may stutter." )
458
+ .arg (incompleteCount),
459
+ QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
460
+ TimeThis tt (" DownloadManager::queryDownloadListInfo()" );
461
+ log ::info (" Querying metadata for every download with incomplete info..." );
460
462
startDisableDirWatcher ();
461
463
for (size_t i = 0 ; i < m_ActiveDownloads.size (); i++) {
462
464
if (isInfoIncomplete (i)) {
463
- queryInfoMd5 (i);
465
+ queryInfoMd5 (i, false );
464
466
}
465
467
}
466
468
endDisableDirWatcher ();
467
- } else {
468
-
469
- // Warn the user if the number of incomplete infos is over 5
470
- QString message = tr (" There are %1 incomplete download meta files.\n\n "
471
- " Do you want to fetch all incomplete metadata?\n "
472
- " API uses will be consumed, and Mod Organizer may stutter." );
473
- message = message.arg (incompleteInfos);
474
- if (QMessageBox::question (m_ParentWidget, tr (" Incomplete Download Infos" ), message,
475
- QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
476
- // Fetch metadata for incomplete download infos
477
- startDisableDirWatcher ();
478
- for (size_t i = 0 ; i < m_ActiveDownloads.size (); i++) {
479
- if (isInfoIncomplete (i)) {
480
- queryInfoMd5 (i);
481
- }
482
- }
483
- endDisableDirWatcher ();
484
- }
485
- return ;
469
+ log ::info (" Metadata has been retrieved successfully!" );
486
470
}
487
-
488
- log ::info (" Metadata has been retrieved successfully!" );
489
471
}
490
472
491
473
bool DownloadManager::addDownload (const QStringList& URLs, QString gameName, int modID,
@@ -1101,10 +1083,18 @@ void DownloadManager::queryInfo(int index)
1101
1083
QString fileName = getFileName (index );
1102
1084
QString ignore;
1103
1085
NexusInterface::interpretNexusFileName (fileName, ignore, info->m_FileInfo ->modID ,
1104
- true );
1086
+ info->m_AskIfNotFound );
1087
+ if (!info->m_AskIfNotFound && (info->m_FileInfo ->modID < 0 ) ||
1088
+ info->m_FileInfo ->gameName .isEmpty ()) {
1089
+ // prevent re-querying (only possible with Nexus)
1090
+ info->m_FileInfo ->repository = " " ;
1091
+ setState (info, STATE_READY);
1092
+ return ;
1093
+ }
1094
+
1105
1095
if (info->m_FileInfo ->modID < 0 ) {
1106
1096
bool ok = false ;
1107
- int modId = QInputDialog::getInt (nullptr , tr (" Please enter the nexus mod id " ),
1097
+ int modId = QInputDialog::getInt (nullptr , tr (" Please enter the Nexus mod ID " ),
1108
1098
tr (" Mod ID:" ), 1 , 1 ,
1109
1099
std::numeric_limits<int >::max (), 1 , &ok);
1110
1100
// careful now: while the dialog was displayed, events were processed.
@@ -1115,7 +1105,7 @@ void DownloadManager::queryInfo(int index)
1115
1105
}
1116
1106
}
1117
1107
1118
- if (info->m_FileInfo ->gameName .size () == 0 ) {
1108
+ if (info->m_FileInfo ->gameName .isEmpty () ) {
1119
1109
SelectionDialog selection (
1120
1110
tr (" Please select the source game code for %1" ).arg (getFileName (index )));
1121
1111
@@ -1138,7 +1128,7 @@ void DownloadManager::queryInfo(int index)
1138
1128
setState (info, STATE_FETCHINGMODINFO);
1139
1129
}
1140
1130
1141
- void DownloadManager::queryInfoMd5 (int index)
1131
+ void DownloadManager::queryInfoMd5 (int index, bool askIfNotFound )
1142
1132
{
1143
1133
if ((index < 0 ) || (index >= m_ActiveDownloads.size ())) {
1144
1134
reportError (tr (" query: invalid download index %1" ).arg (index ));
@@ -1195,8 +1185,9 @@ void DownloadManager::queryInfoMd5(int index)
1195
1185
progress.close ();
1196
1186
downloadFile.close ();
1197
1187
1198
- info->m_Hash = hash.result ();
1199
- info->m_ReQueried = true ;
1188
+ info->m_Hash = hash.result ();
1189
+ info->m_ReQueried = true ;
1190
+ info->m_AskIfNotFound = askIfNotFound;
1200
1191
setState (info, STATE_FETCHINGMODINFO_MD5);
1201
1192
}
1202
1193
0 commit comments