improvement in support for detection of bad downloads (fakes, etc.): queue-scripts are now called after every downloaded file included in nzb; new event "FILE_DOWNLOADED" of parameter "NZBNA_EVENT"; event "UNPACK" removed; instead added event "NZB_DOWNLOADED" which is similar to "UNPACK" but is called for every download even not having archive files and even if unpack is disabled; the execution of queue-scripts is serialized - only one script is executed at a time and other scripts wait in script-queue; the script-queue is compressed so that the same script for the same event is not queued more than once; this reduces the number of calls of scripts if files are downloaded faster than queue-scripts can work up them; a call for event "NZB_DOWNLOADED" is always performed even if the previous calls for events "FILE_DOWNLOADED" were skipped; when a script marks nzb as bad the nzb is deleted from queue, no further internal post-processing (par, unrar, etc.) is made for the nzb but all post-processing scripts are executed; if option "DeleteCleanupDisk" is active the already downloaded files are deleted; new status "BAD" for field "DeleteStatus" of nzb-item in RPC-method "history"; queue-scripts can set post-processing parameters by printing special command, just like post-processing-scripts can do that; this simplifies transferring (of small amount) of information between queue-scripts and post-processing-scripts

This commit is contained in:
Andrey Prygunkov
2014-08-15 22:24:53 +00:00
parent ebe955020c
commit f439f09c2e
12 changed files with 349 additions and 122 deletions

View File

@@ -622,6 +622,7 @@ bool QueueEditor::EditGroup(NZBInfo* pNZBInfo, DownloadQueue::EEditAction eActio
{
ItemList itemList;
bool bAllPaused = true;
int iID = pNZBInfo->GetID();
// collecting files belonging to group
for (FileList::iterator it = pNZBInfo->GetFileList()->begin(); it != pNZBInfo->GetFileList()->end(); it++)
@@ -633,6 +634,15 @@ bool QueueEditor::EditGroup(NZBInfo* pNZBInfo, DownloadQueue::EEditAction eActio
if (eAction == DownloadQueue::eaGroupDelete || eAction == DownloadQueue::eaGroupDupeDelete || eAction == DownloadQueue::eaGroupFinalDelete)
{
if (pNZBInfo->GetFileList()->empty())
{
// special case: something wrong happen with the nzb - it doesn't have any files.
// just nuke it
m_pDownloadQueue->GetQueue()->Remove(pNZBInfo);
delete pNZBInfo;
return false;
}
pNZBInfo->SetDeleting(true);
pNZBInfo->SetAvoidHistory(eAction == DownloadQueue::eaGroupFinalDelete);
pNZBInfo->SetDeletePaused(bAllPaused);
@@ -670,7 +680,17 @@ bool QueueEditor::EditGroup(NZBInfo* pNZBInfo, DownloadQueue::EEditAction eActio
(DownloadQueue::EEditAction)0,
(DownloadQueue::EEditAction)0 };
return InternEditList(&itemList, NULL, GroupToFileMap[eAction], iOffset, szText);
bool bOK = InternEditList(&itemList, NULL, GroupToFileMap[eAction], iOffset, szText);
if ((eAction == DownloadQueue::eaGroupDelete || eAction == DownloadQueue::eaGroupDupeDelete || eAction == DownloadQueue::eaGroupFinalDelete) &&
// NZBInfo could have been destroyed already
m_pDownloadQueue->GetQueue()->Find(iID))
{
DownloadQueue::Aspect deleteAspect = { DownloadQueue::eaNzbDeleted, m_pDownloadQueue, pNZBInfo, NULL };
m_pDownloadQueue->Notify(&deleteAspect);
}
return bOK;
}
void QueueEditor::PauseParsInGroups(ItemList* pItemList, bool bExtraParsOnly)
@@ -899,6 +919,11 @@ void QueueEditor::SetNZBName(NZBInfo* pNZBInfo, const char* szName)
*/
bool QueueEditor::CanCleanupDisk(NZBInfo* pNZBInfo)
{
if (pNZBInfo->GetDeleteStatus() != NZBInfo::dsNone)
{
return true;
}
for (FileList::iterator it = pNZBInfo->GetFileList()->begin(); it != pNZBInfo->GetFileList()->end(); it++)
{
FileInfo* pFileInfo = *it;