void PrePostProcessor::NZBCompleted(DownloadQueue* pDownloadQueue, NZBInfo* pNZBInfo, bool bSaveQueue) { if (g_pOptions->GetKeepHistory() > 0) { //remove old item for the same NZB for (HistoryList::iterator it = pDownloadQueue->GetHistoryList()->begin(); it != pDownloadQueue->GetHistoryList()->end(); it++) { HistoryInfo* pHistoryInfo = *it; if (pHistoryInfo->GetNZBInfo() == pNZBInfo) { delete pHistoryInfo; pDownloadQueue->GetHistoryList()->erase(it); break; } } HistoryInfo* pHistoryInfo = new HistoryInfo(pNZBInfo); pHistoryInfo->SetTime(time(NULL)); pDownloadQueue->GetHistoryList()->push_front(pHistoryInfo); // park files int iParkedFiles = 0; int index = 0; for (FileQueue::iterator it = pDownloadQueue->GetFileQueue()->begin(); it != pDownloadQueue->GetFileQueue()->end(); ) { FileInfo* pFileInfo = *it; if (pFileInfo->GetNZBInfo() == pNZBInfo && !pFileInfo->GetDeleted()) { detail("Park file %s", pFileInfo->GetFilename()); g_pQueueCoordinator->DiscardDiskFile(pFileInfo); pDownloadQueue->GetFileQueue()->erase(it); pDownloadQueue->GetParkedFiles()->push_back(pFileInfo); it = pDownloadQueue->GetFileQueue()->begin() + index; iParkedFiles++; } else { it++; index++; } } pNZBInfo->SetParkedFileCount(iParkedFiles); if (bSaveQueue) { SaveQueue(pDownloadQueue); } info("Collection %s added to history", pNZBInfo->GetName()); } }
void HistoryCoordinator::AddToHistory(DownloadQueue* pDownloadQueue, NZBInfo* pNZBInfo) { //remove old item for the same NZB for (HistoryList::iterator it = pDownloadQueue->GetHistory()->begin(); it != pDownloadQueue->GetHistory()->end(); it++) { HistoryInfo* pHistoryInfo = *it; if (pHistoryInfo->GetNZBInfo() == pNZBInfo) { delete pHistoryInfo; pDownloadQueue->GetHistory()->erase(it); break; } } HistoryInfo* pHistoryInfo = new HistoryInfo(pNZBInfo); pHistoryInfo->SetTime(time(NULL)); pDownloadQueue->GetHistory()->push_front(pHistoryInfo); pDownloadQueue->GetQueue()->Remove(pNZBInfo); if (pNZBInfo->GetDeleteStatus() == NZBInfo::dsNone) { // park files and delete files marked for deletion int iParkedFiles = 0; for (FileList::iterator it = pNZBInfo->GetFileList()->begin(); it != pNZBInfo->GetFileList()->end(); ) { FileInfo* pFileInfo = *it; if (!pFileInfo->GetDeleted()) { detail("Parking file %s", pFileInfo->GetFilename()); g_pQueueCoordinator->DiscardDiskFile(pFileInfo); iParkedFiles++; it++; } else { // since we removed pNZBInfo from queue we need to take care of removing file infos marked for deletion pNZBInfo->GetFileList()->erase(it); delete pFileInfo; it = pNZBInfo->GetFileList()->begin() + iParkedFiles; } } pNZBInfo->SetParkedFileCount(iParkedFiles); } else { pNZBInfo->GetFileList()->Clear(); } pNZBInfo->PrintMessage(Message::mkInfo, "Collection %s added to history", pNZBInfo->GetName()); }
void HistoryCoordinator::HistoryHide(DownloadQueue* pDownloadQueue, HistoryInfo* pHistoryInfo, int rindex) { char szNiceName[1024]; pHistoryInfo->GetName(szNiceName, 1024); // replace history element DupInfo* pDupInfo = new DupInfo(); pDupInfo->SetID(pHistoryInfo->GetNZBInfo()->GetID()); pDupInfo->SetName(pHistoryInfo->GetNZBInfo()->GetName()); pDupInfo->SetDupeKey(pHistoryInfo->GetNZBInfo()->GetDupeKey()); pDupInfo->SetDupeScore(pHistoryInfo->GetNZBInfo()->GetDupeScore()); pDupInfo->SetDupeMode(pHistoryInfo->GetNZBInfo()->GetDupeMode()); pDupInfo->SetSize(pHistoryInfo->GetNZBInfo()->GetSize()); pDupInfo->SetFullContentHash(pHistoryInfo->GetNZBInfo()->GetFullContentHash()); pDupInfo->SetFilteredContentHash(pHistoryInfo->GetNZBInfo()->GetFilteredContentHash()); pDupInfo->SetStatus( pHistoryInfo->GetNZBInfo()->GetMarkStatus() == NZBInfo::ksGood ? DupInfo::dsGood : pHistoryInfo->GetNZBInfo()->GetMarkStatus() == NZBInfo::ksBad ? DupInfo::dsBad : pHistoryInfo->GetNZBInfo()->GetMarkStatus() == NZBInfo::ksSuccess ? DupInfo::dsSuccess : pHistoryInfo->GetNZBInfo()->GetDeleteStatus() == NZBInfo::dsDupe ? DupInfo::dsDupe : pHistoryInfo->GetNZBInfo()->GetDeleteStatus() == NZBInfo::dsManual || pHistoryInfo->GetNZBInfo()->GetDeleteStatus() == NZBInfo::dsGood || pHistoryInfo->GetNZBInfo()->GetDeleteStatus() == NZBInfo::dsCopy ? DupInfo::dsDeleted : pHistoryInfo->GetNZBInfo()->IsDupeSuccess() ? DupInfo::dsSuccess : DupInfo::dsFailed); HistoryInfo* pNewHistoryInfo = new HistoryInfo(pDupInfo); pNewHistoryInfo->SetTime(pHistoryInfo->GetTime()); (*pDownloadQueue->GetHistory())[pDownloadQueue->GetHistory()->size() - 1 - rindex] = pNewHistoryInfo; DeleteDiskFiles(pHistoryInfo->GetNZBInfo()); delete pHistoryInfo; info("Collection %s removed from history", szNiceName); }