/*--- Received when a download has ended ---*/ void Downloader::FileFinished(QNetworkReply* mreply) { qDebug() << "Downloader::FileFinished"; disconnect(reply, SIGNAL(readyRead()), this, SLOT(FilePart())); disconnect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(FileError(QNetworkReply::NetworkError))); mreply->deleteLater(); lastDownloadedSize = 0; downloadedSize = 0; if (bDownloading) { bDownloading = false; timeoutTimer->stop(); currentFile->close(); delete currentFile; if (currentFtpFile == FTP_RELEASE_NOTES_FILE) { emit Stage1(); DownloadFile(FTP_MANIFEST_ROOT, FTP_MANIFEST_FILE); } else if (currentFtpFile == FTP_MANIFEST_FILE) { emit Stage2(); } else { emit FileDownloaded(); } } }
void PrePostProcessor::DownloadQueueUpdate(void* aspect) { if (IsStopped()) { return; } DownloadQueue::Aspect* queueAspect = (DownloadQueue::Aspect*)aspect; if (queueAspect->action == DownloadQueue::eaNzbFound) { NzbFound(queueAspect->downloadQueue, queueAspect->nzbInfo); } else if (queueAspect->action == DownloadQueue::eaNzbAdded) { NzbAdded(queueAspect->downloadQueue, queueAspect->nzbInfo); } else if (queueAspect->action == DownloadQueue::eaNzbNamed) { g_QueueScriptCoordinator->EnqueueScript(queueAspect->nzbInfo, QueueScriptCoordinator::qeNzbNamed); } else if (queueAspect->action == DownloadQueue::eaNzbDeleted && queueAspect->nzbInfo->GetDeleting() && !queueAspect->nzbInfo->GetPostInfo() && queueAspect->nzbInfo->GetFileList()->empty()) { // the deleting of nzbs is usually handled via eaFileDeleted-event, but when deleting nzb without // any files left the eaFileDeleted-event is not fired and we need to process eaNzbDeleted-event instead queueAspect->nzbInfo->PrintMessage(Message::mkInfo, "Collection %s deleted from queue", queueAspect->nzbInfo->GetName()); NzbDeleted(queueAspect->downloadQueue, queueAspect->nzbInfo); } else if ((queueAspect->action == DownloadQueue::eaFileCompleted || queueAspect->action == DownloadQueue::eaFileDeleted)) { if (queueAspect->action == DownloadQueue::eaFileCompleted) { FileDownloaded(queueAspect->downloadQueue, queueAspect->nzbInfo, queueAspect->fileInfo); } #ifndef DISABLE_PARCHECK for (NzbInfo* postJob : m_activeJobs) { if (postJob && queueAspect->fileInfo->GetNzbInfo() == postJob && postJob->GetPostInfo() && postJob->GetPostInfo()->GetPostThread() && postJob->GetPostInfo()->GetStage() >= PostInfo::ptLoadingPars && postJob->GetPostInfo()->GetStage() <= PostInfo::ptVerifyingRepaired && ((RepairController*)postJob->GetPostInfo()->GetPostThread())->AddPar( queueAspect->fileInfo, queueAspect->action == DownloadQueue::eaFileDeleted)) { return; } } #endif if ((queueAspect->action == DownloadQueue::eaFileCompleted || queueAspect->fileInfo->GetDupeDeleted()) && queueAspect->fileInfo->GetNzbInfo()->GetDeleteStatus() != NzbInfo::dsHealth && !queueAspect->nzbInfo->GetPostInfo() && queueAspect->nzbInfo->IsDownloadCompleted(true)) { queueAspect->nzbInfo->PrintMessage(Message::mkInfo, "Collection %s completely downloaded", queueAspect->nzbInfo->GetName()); g_QueueScriptCoordinator->EnqueueScript(queueAspect->nzbInfo, QueueScriptCoordinator::qeNzbDownloaded); NzbDownloaded(queueAspect->downloadQueue, queueAspect->nzbInfo); } else if ((queueAspect->action == DownloadQueue::eaFileDeleted || (queueAspect->action == DownloadQueue::eaFileCompleted && queueAspect->fileInfo->GetNzbInfo()->GetDeleteStatus() > NzbInfo::dsNone)) && !queueAspect->nzbInfo->GetPostInfo() && queueAspect->nzbInfo->IsDownloadCompleted(false)) { queueAspect->nzbInfo->PrintMessage(Message::mkInfo, "Collection %s deleted from queue", queueAspect->nzbInfo->GetName()); NzbDeleted(queueAspect->downloadQueue, queueAspect->nzbInfo); } } }