diff --git a/daemon/queue/DupeCoordinator.cpp b/daemon/queue/DupeCoordinator.cpp index e23807db1..679b5fb2c 100644 --- a/daemon/queue/DupeCoordinator.cpp +++ b/daemon/queue/DupeCoordinator.cpp @@ -270,6 +270,7 @@ void DupeCoordinator::NzbFound(DownloadQueue* downloadQueue, NzbInfo* nzbInfo) { NzbInfo* queuedNzbInfo = (*it++).get(); if (queuedNzbInfo != nzbInfo && + queuedNzbInfo->GetDeleteStatus() == NzbInfo::dsNone && (queuedNzbInfo->GetKind() == NzbInfo::nkNzb || (queuedNzbInfo->GetKind() == NzbInfo::nkUrl && nzbInfo->GetKind() == NzbInfo::nkUrl)) && queuedNzbInfo->GetDupeMode() != dmForce && @@ -294,9 +295,13 @@ void DupeCoordinator::NzbFound(DownloadQueue* downloadQueue, NzbInfo* nzbInfo) // the existing queue item is moved to history as dupe-backup info("Moving collection %s with lower duplicate score to history", queuedNzbInfo->GetName()); queuedNzbInfo->SetDeleteStatus(NzbInfo::dsDupe); + int oldSize = downloadQueue->GetQueue()->size(); downloadQueue->EditEntry(queuedNzbInfo->GetId(), DownloadQueue::eaGroupDelete, nullptr); + int newSize = downloadQueue->GetQueue()->size(); + index += oldSize == newSize ? 1 : 0; it = downloadQueue->GetQueue()->begin() + index; + index--; } } } diff --git a/daemon/queue/UrlCoordinator.cpp b/daemon/queue/UrlCoordinator.cpp index 4f9c8c137..7cc2303bb 100644 --- a/daemon/queue/UrlCoordinator.cpp +++ b/daemon/queue/UrlCoordinator.cpp @@ -277,8 +277,6 @@ void UrlCoordinator::UrlCompleted(UrlDownloader* urlDownloader) // remove downloader from downloader list m_activeDownloads.erase(std::find(m_activeDownloads.begin(), m_activeDownloads.end(), urlDownloader)); - nzbInfo->SetActiveDownloads(0); - retry = urlDownloader->GetStatus() == WebDownloader::adRetry && !nzbInfo->GetDeleting(); if (nzbInfo->GetDeleting()) @@ -309,6 +307,7 @@ void UrlCoordinator::UrlCompleted(UrlDownloader* urlDownloader) if (retry) { + nzbInfo->SetActiveDownloads(0); return; } @@ -324,7 +323,7 @@ void UrlCoordinator::UrlCompleted(UrlDownloader* urlDownloader) if (addStatus == Scanner::asSuccess) { - // if scanner has successfully added nzb-file to queue, our pNZBInfo is + // if scanner has successfully added nzb-file to queue, our nzbInfo is // already removed from queue and destroyed return; } @@ -339,6 +338,8 @@ void UrlCoordinator::UrlCompleted(UrlDownloader* urlDownloader) { GuardedDownloadQueue downloadQueue = DownloadQueue::Guard(); + nzbInfo->SetActiveDownloads(0); + DownloadQueue::Aspect aspect = {DownloadQueue::eaUrlFailed, downloadQueue, nzbInfo, nullptr}; downloadQueue->Notify(&aspect); } @@ -360,6 +361,8 @@ bool UrlCoordinator::DeleteQueueEntry(DownloadQueue* downloadQueue, NzbInfo* nzb return true; } } + + return false; } info("Deleting URL %s", nzbInfo->GetName());