From 03b057be64da9ef77102a94e12bfd14cdf8a67e9 Mon Sep 17 00:00:00 2001 From: Andrey Prygunkov Date: Sun, 22 Jun 2008 22:27:52 +0000 Subject: [PATCH] added the option to help to post-process-scripts, which make par-check/-repair on it's own --- Options.cpp | 3 +++ Options.h | 2 ++ PrePostProcessor.cpp | 4 ++-- nzbget.conf.example | 17 +++++++++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Options.cpp b/Options.cpp index b797f948..78571cfa 100644 --- a/Options.cpp +++ b/Options.cpp @@ -138,6 +138,7 @@ static const char* OPTION_NZBDIRFILEAGE = "NzbDirFileAge"; static const char* OPTION_PARCLEANUPQUEUE = "ParCleanupQueue"; static const char* OPTION_DISKSPACE = "DiskSpace"; static const char* OPTION_POSTLOGKIND = "PostLogKind"; +static const char* OPTION_ALLOWREPROCESS = "AllowReProcess"; #ifndef WIN32 const char* PossibleConfigLocations[] = @@ -425,6 +426,7 @@ void Options::InitDefault() SetOption(OPTION_PARCLEANUPQUEUE, "no"); SetOption(OPTION_DISKSPACE, "0"); SetOption(OPTION_POSTLOGKIND, "none"); + SetOption(OPTION_ALLOWREPROCESS, "no"); } void Options::InitOptFile() @@ -567,6 +569,7 @@ void Options::InitOptions() m_bDirectWrite = (bool)ParseOptionValue(OPTION_DIRECTWRITE, BoolCount, BoolNames, BoolValues); m_bParCleanupQueue = (bool)ParseOptionValue(OPTION_PARCLEANUPQUEUE, BoolCount, BoolNames, BoolValues); m_bDecode = (bool)ParseOptionValue(OPTION_DECODE, BoolCount, BoolNames, BoolValues); + m_bAllowReProcess = (bool)ParseOptionValue(OPTION_ALLOWREPROCESS, BoolCount, BoolNames, BoolValues); const char* OutputModeNames[] = { "loggable", "logable", "log", "colored", "color", "ncurses", "curses" }; const int OutputModeValues[] = { omLoggable, omLoggable, omLoggable, omColored, omColored, omNCurses, omNCurses }; diff --git a/Options.h b/Options.h index cf7fee25..7bf5f33f 100644 --- a/Options.h +++ b/Options.h @@ -144,6 +144,7 @@ private: bool m_bParCleanupQueue; int m_iDiskSpace; EPostLogKind m_ePostLogKind; + bool m_bAllowReProcess; // Parsed command-line parameters bool m_bServerMode; @@ -242,6 +243,7 @@ public: bool GetParCleanupQueue() { return m_bParCleanupQueue; } int GetDiskSpace() { return m_iDiskSpace; } EPostLogKind GetPostLogKind() { return m_ePostLogKind; } + bool GetAllowReProcess() { return m_bAllowReProcess; } // Parsed command-line parameters bool GetServerMode() { return m_bServerMode; } diff --git a/PrePostProcessor.cpp b/PrePostProcessor.cpp index d104abdb..28f7447e 100644 --- a/PrePostProcessor.cpp +++ b/PrePostProcessor.cpp @@ -510,7 +510,7 @@ bool PrePostProcessor::CheckScript(FileInfo * pFileInfo) if (m_bPostScript && !JobExists(&m_PostQueue, pFileInfo->GetNZBInfo()->GetFilename()) && - !JobExists(&m_CompletedJobs, pFileInfo->GetNZBInfo()->GetFilename())) + (!JobExists(&m_CompletedJobs, pFileInfo->GetNZBInfo()->GetFilename()) || g_pOptions->GetAllowReProcess())) { m_mutexQueue.Lock(); @@ -676,7 +676,7 @@ bool PrePostProcessor::CheckPars(DownloadQueue * pDownloadQueue, FileInfo * pFil szFullFilename[1024-1] = '\0'; if (!ParJobExists(&m_PostQueue, szFullFilename) && - !ParJobExists(&m_CompletedJobs, szFullFilename)) + (!ParJobExists(&m_CompletedJobs, szFullFilename) || g_pOptions->GetAllowReProcess())) { char szInfoName[1024]; int iBaseLen = 0; diff --git a/nzbget.conf.example b/nzbget.conf.example index 2328f46b..715223eb 100644 --- a/nzbget.conf.example +++ b/nzbget.conf.example @@ -439,6 +439,23 @@ ParCleanupQueue=yes # NOTE 4: do not forget to uncomment the next line #PostProcess=~/myscript.sh +# Allow multiple post-processing for the same nzb-file (yes,no) +# After the post-processing (par-check and call of a postprocess-script) is +# completed, nzbget adds the nzb-file to a list of completed-jobs. The nzb-file +# stays in the list until the last file from that nzb-file is deleted from +# the download queue (it occurs straight away if the par-check was successful +# and the option "ParCleanupQueue" was set). +# So, if there were paused files in queue and they will be unpaused (manually +# or from a post-process-script) nzbget will not post-process nzb-file again. +# This prevents the unwanted multiple post-processing of the same nzb-file. +# But it might be needed if the par-check/-repair are performed not directly +# by nzbget but from a post-process-script. +# NOTE 1: it is recommended to keep the option disabled. You should enable it +# only if it is suggested by a post-process-script's author. +# NOTE 2: by enabling "AllowReProcess" you should disable the option "ParCheck" +# to prevent multiple par-checking. +AllowReProcess=no + # Set the default message-kind for output received from postprocess-script # (None, Detail, Info, Warning, Error, Debug). # NZBGet checks if the line written by the script to stdout or stderr starts