/** * Removes old entries from (recent) history */ void HistoryCoordinator::ServiceWork() { GuardedDownloadQueue downloadQueue = DownloadQueue::Guard(); time_t minTime = Util::CurrentTime() - g_Options->GetKeepHistory() * 60*60*24; bool changed = false; int index = 0; // traversing in a reverse order to delete items in order they were added to history // (just to produce the log-messages in a more logical order) for (HistoryList::reverse_iterator it = downloadQueue->GetHistory()->rbegin(); it != downloadQueue->GetHistory()->rend(); ) { HistoryInfo* historyInfo = (*it).get(); if (historyInfo->GetKind() != HistoryInfo::hkDup && historyInfo->GetTime() < minTime) { if (g_Options->GetDupeCheck() && historyInfo->GetKind() == HistoryInfo::hkNzb) { // replace history element HistoryHide(downloadQueue, historyInfo, index); index++; } else { if (historyInfo->GetKind() == HistoryInfo::hkNzb) { DeleteDiskFiles(historyInfo->GetNzbInfo()); } info("Collection %s removed from history", historyInfo->GetName()); downloadQueue->GetHistory()->erase(downloadQueue->GetHistory()->end() - 1 - index); } it = downloadQueue->GetHistory()->rbegin() + index; changed = true; } else { it++; index++; } } if (changed) { downloadQueue->HistoryChanged(); downloadQueue->Save(); } }
NzbInfo* QueueScriptCoordinator::FindNzbInfo(DownloadQueue* downloadQueue, int nzbId) { NzbInfo* nzbInfo = downloadQueue->GetQueue()->Find(nzbId); if (nzbInfo) { return nzbInfo; } HistoryInfo* historyInfo = downloadQueue->GetHistory()->Find(nzbId); if (historyInfo) { return historyInfo->GetNzbInfo(); } return nullptr; }
void HistoryCoordinator::PrepareEdit(DownloadQueue* downloadQueue, IdList* idList, DownloadQueue::EEditAction action) { // First pass: when marking multiple items - mark them bad without performing the mark-logic, // this will later (on second step) avoid moving other items to download queue, if they are marked bad too. if (action == DownloadQueue::eaHistoryMarkBad) { for (int id : *idList) { HistoryInfo* historyInfo = downloadQueue->GetHistory()->Find(id); if (historyInfo && historyInfo->GetKind() == HistoryInfo::hkNzb) { historyInfo->GetNzbInfo()->SetMarkStatus(NzbInfo::ksBad); } } } }