diff options
| author | Silarn <jrim@rimpo.org> | 2018-04-07 23:54:22 -0500 |
|---|---|---|
| committer | Silarn <jrim@rimpo.org> | 2018-04-07 23:54:22 -0500 |
| commit | 7eba6837dd65eb0e5f3b9f71e67e82fe553a56a6 (patch) | |
| tree | cc59fac270bcf40b2e5729a7b9c3410c054916de /src/downloadmanager.cpp | |
| parent | cc2bd152568a4f1164a0a4ba5e6232e77e7c9945 (diff) | |
Prevent redownloading a mod if the download is still in progress
Diffstat (limited to 'src/downloadmanager.cpp')
| -rw-r--r-- | src/downloadmanager.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index c0d7fbf3..45070885 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -460,10 +460,25 @@ void DownloadManager::addNXMDownload(const QString &url) return;
}
- if (m_PendingDownloads.contains(std::pair<int, int>(nxmInfo.modId(), nxmInfo.fileId()))) {
- qDebug("download requested is already started (mod: %s, file: %s)", qPrintable(nxmInfo.modId()), qPrintable(nxmInfo.fileId()));
- QMessageBox::information(nullptr, tr("Already Started"), tr("A download for this mod file has already been started."), QMessageBox::Ok);
- return;
+ for (auto pair : m_PendingDownloads) {
+ if (pair.first == nxmInfo.modId() && pair.second == nxmInfo.fileId()) {
+ qDebug("download requested is already started (mod id: %s, file id: %s)", qPrintable(nxmInfo.modId()), qPrintable(nxmInfo.fileId()));
+ QMessageBox::information(nullptr, tr("Already Started"), tr("A download for this mod file has already been queued."), QMessageBox::Ok);
+ return;
+ }
+ }
+
+ for (DownloadInfo *download : m_ActiveDownloads) {
+ if (download->m_FileInfo->modID == nxmInfo.modId() && download->m_FileInfo->fileID == nxmInfo.fileId()) {
+ if (download->m_State == STATE_DOWNLOADING || download->m_State == STATE_PAUSED || download->m_State == STATE_STARTED) {
+ qDebug("download requested is already started (mod: %s, file: %s)", qPrintable(download->m_FileInfo->modName),
+ qPrintable(download->m_FileInfo->fileName));
+
+ QMessageBox::information(nullptr, tr("Already Started"), tr("There is already a download started for this file (%2).")
+ .arg(download->m_FileInfo->modName).arg(download->m_FileInfo->name), QMessageBox::Ok);
+ return;
+ }
+ }
}
emit aboutToUpdate();
|
