From af111adbde4cd607bcafb3a907d69dd957a59a2e Mon Sep 17 00:00:00 2001 From: Andrey Prygunkov Date: Sat, 28 Oct 2017 16:17:45 +0200 Subject: [PATCH] #461: removed options "SaveQueue" and "ReloadQueue" --- daemon/feed/FeedCoordinator.cpp | 4 ++-- daemon/main/Options.cpp | 12 +++++------ daemon/main/Options.h | 4 ---- daemon/nntp/ArticleWriter.cpp | 4 ++-- daemon/postprocess/PrePostProcessor.cpp | 2 +- daemon/queue/DownloadInfo.cpp | 2 +- daemon/queue/HistoryCoordinator.cpp | 2 +- daemon/queue/NzbFile.cpp | 2 +- daemon/queue/QueueCoordinator.cpp | 28 ++++++++++++------------- tests/queue/NzbFileTest.cpp | 1 - 10 files changed, 27 insertions(+), 34 deletions(-) diff --git a/daemon/feed/FeedCoordinator.cpp b/daemon/feed/FeedCoordinator.cpp index c4fa4a7b..8de46088 100644 --- a/daemon/feed/FeedCoordinator.cpp +++ b/daemon/feed/FeedCoordinator.cpp @@ -87,7 +87,7 @@ void FeedCoordinator::Run() usleep(20 * 1000); } - if (g_Options->GetServerMode() && g_Options->GetSaveQueue() && g_Options->GetReloadQueue()) + if (g_Options->GetServerMode()) { Guard guard(m_downloadsMutex); g_DiskState->LoadFeeds(&m_feeds, &m_feedHistory); @@ -651,7 +651,7 @@ void FeedCoordinator::CheckSaveFeeds() Guard guard(m_downloadsMutex); if (m_save) { - if (g_Options->GetSaveQueue() && g_Options->GetServerMode()) + if (g_Options->GetServerMode()) { g_DiskState->SaveFeeds(&m_feeds, &m_feedHistory); } diff --git a/daemon/main/Options.cpp b/daemon/main/Options.cpp index 2e918a2c..135ee2d8 100644 --- a/daemon/main/Options.cpp +++ b/daemon/main/Options.cpp @@ -70,9 +70,7 @@ static const char* OPTION_AUTHORIZEDIP = "AuthorizedIP"; static const char* OPTION_ARTICLETIMEOUT = "ArticleTimeout"; static const char* OPTION_URLTIMEOUT = "UrlTimeout"; static const char* OPTION_REMOTETIMEOUT = "RemoteTimeout"; -static const char* OPTION_SAVEQUEUE = "SaveQueue"; static const char* OPTION_FLUSHQUEUE = "FlushQueue"; -static const char* OPTION_RELOADQUEUE = "ReloadQueue"; static const char* OPTION_BROKENLOG = "BrokenLog"; static const char* OPTION_NZBLOG = "NzbLog"; static const char* OPTION_RAWARTICLE = "RawArticle"; @@ -172,6 +170,8 @@ static const char* OPTION_SCANSCRIPT = "ScanScript"; static const char* OPTION_QUEUESCRIPT = "QueueScript"; static const char* OPTION_FEEDSCRIPT = "FeedScript"; static const char* OPTION_DECODE = "Decode"; +static const char* OPTION_SAVEQUEUE = "SaveQueue"; +static const char* OPTION_RELOADQUEUE = "ReloadQueue"; const char* BoolNames[] = { "yes", "no", "true", "false", "1", "0", "on", "off", "enable", "disable", "enabled", "disabled" }; const int BoolValues[] = { 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 }; @@ -448,9 +448,7 @@ void Options::InitDefaults() SetOption(OPTION_ARTICLETIMEOUT, "60"); SetOption(OPTION_URLTIMEOUT, "60"); SetOption(OPTION_REMOTETIMEOUT, "90"); - SetOption(OPTION_SAVEQUEUE, "yes"); SetOption(OPTION_FLUSHQUEUE, "yes"); - SetOption(OPTION_RELOADQUEUE, "yes"); SetOption(OPTION_BROKENLOG, "yes"); SetOption(OPTION_NZBLOG, "yes"); SetOption(OPTION_RAWARTICLE, "no"); @@ -740,7 +738,6 @@ void Options::InitOptions() m_nzbLog = (bool)ParseEnumValue(OPTION_NZBLOG, BoolCount, BoolNames, BoolValues); m_appendCategoryDir = (bool)ParseEnumValue(OPTION_APPENDCATEGORYDIR, BoolCount, BoolNames, BoolValues); m_continuePartial = (bool)ParseEnumValue(OPTION_CONTINUEPARTIAL, BoolCount, BoolNames, BoolValues); - m_saveQueue = (bool)ParseEnumValue(OPTION_SAVEQUEUE, BoolCount, BoolNames, BoolValues); m_flushQueue = (bool)ParseEnumValue(OPTION_FLUSHQUEUE, BoolCount, BoolNames, BoolValues); m_dupeCheck = (bool)ParseEnumValue(OPTION_DUPECHECK, BoolCount, BoolNames, BoolValues); m_parRepair = (bool)ParseEnumValue(OPTION_PARREPAIR, BoolCount, BoolNames, BoolValues); @@ -748,7 +745,6 @@ void Options::InitOptions() m_parRename = (bool)ParseEnumValue(OPTION_PARRENAME, BoolCount, BoolNames, BoolValues); m_rarRename = (bool)ParseEnumValue(OPTION_RARRENAME, BoolCount, BoolNames, BoolValues); m_directRename = (bool)ParseEnumValue(OPTION_DIRECTRENAME, BoolCount, BoolNames, BoolValues); - m_reloadQueue = (bool)ParseEnumValue(OPTION_RELOADQUEUE, BoolCount, BoolNames, BoolValues); m_cursesNzbName = (bool)ParseEnumValue(OPTION_CURSESNZBNAME, BoolCount, BoolNames, BoolValues); m_cursesTime = (bool)ParseEnumValue(OPTION_CURSESTIME, BoolCount, BoolNames, BoolValues); m_cursesGroup = (bool)ParseEnumValue(OPTION_CURSESGROUP, BoolCount, BoolNames, BoolValues); @@ -1610,7 +1606,9 @@ bool Options::ValidateOptionName(const char* optname, const char* optvalue) !strcasecmp(optname, OPTION_RELOADPOSTQUEUE) || !strcasecmp(optname, OPTION_PARCLEANUPQUEUE) || !strcasecmp(optname, OPTION_DELETECLEANUPDISK) || - !strcasecmp(optname, OPTION_HISTORYCLEANUPDISK)) + !strcasecmp(optname, OPTION_HISTORYCLEANUPDISK) || + !strcasecmp(optname, OPTION_SAVEQUEUE) || + !strcasecmp(optname, OPTION_RELOADQUEUE)) { ConfigWarn("Option \"%s\" is obsolete, ignored", optname); return true; diff --git a/daemon/main/Options.h b/daemon/main/Options.h index 97279fc0..7a2ff0ac 100644 --- a/daemon/main/Options.h +++ b/daemon/main/Options.h @@ -222,7 +222,6 @@ public: int GetArticleInterval() { return m_articleInterval; } int GetUrlRetries() { return m_urlRetries; } int GetUrlInterval() { return m_urlInterval; } - bool GetSaveQueue() { return m_saveQueue; } bool GetFlushQueue() { return m_flushQueue; } bool GetDupeCheck() { return m_dupeCheck; } const char* GetControlIp() { return m_controlIp; } @@ -244,7 +243,6 @@ public: const char* GetLockFile() { return m_lockFile; } const char* GetDaemonUsername() { return m_daemonUsername; } EOutputMode GetOutputMode() { return m_outputMode; } - bool GetReloadQueue() { return m_reloadQueue; } int GetUrlConnections() { return m_urlConnections; } int GetLogBufferSize() { return m_logBufferSize; } EWriteLog GetWriteLog() { return m_writeLog; } @@ -377,7 +375,6 @@ private: int m_articleInterval = 0; int m_urlRetries = 0; int m_urlInterval = 0; - bool m_saveQueue = false; bool m_flushQueue = false; bool m_dupeCheck = false; CString m_controlIp; @@ -399,7 +396,6 @@ private: CString m_lockFile; CString m_daemonUsername; EOutputMode m_outputMode = omLoggable; - bool m_reloadQueue = false; int m_urlConnections = 0; int m_logBufferSize = 0; EWriteLog m_writeLog = wlAppend; diff --git a/daemon/nntp/ArticleWriter.cpp b/daemon/nntp/ArticleWriter.cpp index 6d972a5f..d95fc16b 100644 --- a/daemon/nntp/ArticleWriter.cpp +++ b/daemon/nntp/ArticleWriter.cpp @@ -825,7 +825,7 @@ CachedSegmentData ArticleCache::Alloc(int size) p = malloc(size); if (p) { - if (!m_allocated && g_Options->GetSaveQueue() && g_Options->GetServerMode() && g_Options->GetContinuePartial()) + if (!m_allocated && g_Options->GetServerMode() && g_Options->GetContinuePartial()) { g_DiskState->WriteCacheFlag(); } @@ -858,7 +858,7 @@ void ArticleCache::Free(CachedSegmentData* segment) Guard guard(m_allocMutex); m_allocated -= segment->m_size; - if (!m_allocated && g_Options->GetSaveQueue() && g_Options->GetServerMode() && g_Options->GetContinuePartial()) + if (!m_allocated && g_Options->GetServerMode() && g_Options->GetContinuePartial()) { g_DiskState->DeleteCacheFlag(); } diff --git a/daemon/postprocess/PrePostProcessor.cpp b/daemon/postprocess/PrePostProcessor.cpp index e8727134..7c9db04d 100644 --- a/daemon/postprocess/PrePostProcessor.cpp +++ b/daemon/postprocess/PrePostProcessor.cpp @@ -52,7 +52,7 @@ void PrePostProcessor::Run() usleep(20 * 1000); } - if (g_Options->GetServerMode() && g_Options->GetSaveQueue() && g_Options->GetReloadQueue()) + if (g_Options->GetServerMode()) { SanitisePostQueue(); } diff --git a/daemon/queue/DownloadInfo.cpp b/daemon/queue/DownloadInfo.cpp index e0ce9b19..ea144a91 100644 --- a/daemon/queue/DownloadInfo.cpp +++ b/daemon/queue/DownloadInfo.cpp @@ -376,7 +376,7 @@ void NzbInfo::AddMessage(Message::EKind kind, const char * text) m_messages.emplace_back(++m_idMessageGen, kind, Util::CurrentTime(), text); - if (g_Options->GetSaveQueue() && g_Options->GetServerMode() && g_Options->GetNzbLog()) + if (g_Options->GetServerMode() && g_Options->GetNzbLog()) { g_DiskState->AppendNzbMessage(m_id, kind, text); m_messageCount++; diff --git a/daemon/queue/HistoryCoordinator.cpp b/daemon/queue/HistoryCoordinator.cpp index 01693cc7..c72c5cea 100644 --- a/daemon/queue/HistoryCoordinator.cpp +++ b/daemon/queue/HistoryCoordinator.cpp @@ -87,7 +87,7 @@ void HistoryCoordinator::ServiceWork() void HistoryCoordinator::DeleteDiskFiles(NzbInfo* nzbInfo) { - if (g_Options->GetSaveQueue() && g_Options->GetServerMode()) + if (g_Options->GetServerMode()) { // delete parked files g_DiskState->DiscardFiles(nzbInfo); diff --git a/daemon/queue/NzbFile.cpp b/daemon/queue/NzbFile.cpp index a7b57547..0630fd93 100644 --- a/daemon/queue/NzbFile.cpp +++ b/daemon/queue/NzbFile.cpp @@ -374,7 +374,7 @@ void NzbFile::ProcessFiles() CalcHashes(); - if (g_Options->GetSaveQueue() && g_Options->GetServerMode()) + if (g_Options->GetServerMode()) { for (FileInfo* fileInfo : m_nzbInfo->GetFileList()) { diff --git a/daemon/queue/QueueCoordinator.cpp b/daemon/queue/QueueCoordinator.cpp index 0fc759a6..5524c051 100644 --- a/daemon/queue/QueueCoordinator.cpp +++ b/daemon/queue/QueueCoordinator.cpp @@ -58,7 +58,7 @@ void QueueCoordinator::CoordinatorDownloadQueue::Save() return; } - if (g_Options->GetSaveQueue() && g_Options->GetServerMode()) + if (g_Options->GetServerMode()) { g_DiskState->SaveDownloadQueue(this, m_historyChanged); m_stateChanged = true; @@ -103,11 +103,11 @@ void QueueCoordinator::Load() bool perfectServerMatch = true; bool queueLoaded = false; - if (g_Options->GetServerMode() && g_Options->GetSaveQueue()) + if (g_Options->GetServerMode()) { statLoaded = g_StatMeter->Load(&perfectServerMatch); - if (g_Options->GetReloadQueue() && g_DiskState->DownloadQueueExists()) + if (g_DiskState->DownloadQueueExists()) { queueLoaded = g_DiskState->LoadDownloadQueue(downloadQueue, g_ServerPool->GetServers()); } @@ -134,7 +134,7 @@ void QueueCoordinator::Load() downloadQueue->Save(); // re-save file states into diskstate to update server ids - if (g_Options->GetServerMode() && g_Options->GetSaveQueue()) + if (g_Options->GetServerMode()) { for (NzbInfo* nzbInfo : downloadQueue->GetQueue()) { @@ -333,7 +333,7 @@ NzbInfo* QueueCoordinator::AddNzbFileToQueue(std::unique_ptr nzbInfo, N for (FileInfo* fileInfo: nzbInfo->GetFileList()) { allPaused &= fileInfo->GetPaused(); - if (g_Options->GetSaveQueue() && g_Options->GetServerMode()) + if (g_Options->GetServerMode()) { g_DiskState->DiscardFile(fileInfo->GetId(), true, false, false); } @@ -437,7 +437,7 @@ void QueueCoordinator::CheckDupeFileInfos(NzbInfo* nzbInfo) { nzbInfo->UpdateDeletedStats(fileInfo); nzbInfo->GetFileList()->Remove(fileInfo); - if (g_Options->GetSaveQueue() && g_Options->GetServerMode()) + if (g_Options->GetServerMode()) { g_DiskState->DiscardFile(fileInfo->GetId(), true, false, false); } @@ -527,7 +527,7 @@ bool QueueCoordinator::GetNextArticle(DownloadQueue* downloadQueue, FileInfo* &f return true; } - if (fileInfo->GetArticles()->empty() && g_Options->GetSaveQueue() && g_Options->GetServerMode()) + if (fileInfo->GetArticles()->empty() && g_Options->GetServerMode()) { g_DiskState->LoadArticles(fileInfo); LoadPartialState(fileInfo); @@ -561,7 +561,7 @@ bool QueueCoordinator::GetNextFirstArticle(NzbInfo* nzbInfo, FileInfo* &fileInfo { if (!fileInfo1->GetFilenameConfirmed()) { - if (fileInfo1->GetArticles()->empty() && g_Options->GetSaveQueue() && g_Options->GetServerMode()) + if (fileInfo1->GetArticles()->empty() && g_Options->GetServerMode()) { g_DiskState->LoadArticles(fileInfo1); LoadPartialState(fileInfo1); @@ -794,7 +794,7 @@ void QueueCoordinator::DeleteFileInfo(DownloadQueue* downloadQueue, FileInfo* fi fileInfo->GetSuccessArticles() > 0 || fileInfo->GetFailedArticles() > 0 ? CompletedFile::cfPartial : CompletedFile::cfNone; - if (g_Options->GetSaveQueue() && g_Options->GetServerMode()) + if (g_Options->GetServerMode()) { g_DiskState->DiscardFile(fileInfo->GetId(), fileStatus == CompletedFile::cfSuccess || (fileDeleted && !parking), true, false); if (fileStatus == CompletedFile::cfPartial && (completed || parking)) @@ -862,7 +862,7 @@ void QueueCoordinator::DiscardTempFiles(FileInfo* fileInfo) void QueueCoordinator::SaveAllPartialState() { - if (!(g_Options->GetServerMode() && g_Options->GetSaveQueue())) + if (!g_Options->GetServerMode()) { return; } @@ -923,7 +923,7 @@ void QueueCoordinator::LoadPartialState(FileInfo* fileInfo) void QueueCoordinator::SaveAllFileState() { - if (g_Options->GetSaveQueue() && g_Options->GetServerMode() && m_downloadQueue.m_stateChanged) + if (g_Options->GetServerMode() && m_downloadQueue.m_stateChanged) { GuardedDownloadQueue downloadQueue = DownloadQueue::Guard(); g_DiskState->SaveAllFileInfos(downloadQueue); @@ -1316,7 +1316,7 @@ void QueueCoordinator::DirectRenameCompleted(DownloadQueue* downloadQueue, NzbIn { for (FileInfo* fileInfo : nzbInfo->GetFileList()) { - if (g_Options->GetSaveQueue() && g_Options->GetServerMode() && !fileInfo->GetArticles()->empty()) + if (g_Options->GetServerMode() && !fileInfo->GetArticles()->empty()) { // save new file name into disk state file g_DiskState->SaveFile(fileInfo); @@ -1391,7 +1391,7 @@ void QueueCoordinator::DiscardDirectRename(DownloadQueue* downloadQueue, NzbInfo fileInfo->SetPartialChanged(false); fileInfo->SetPartialState(FileInfo::psNone); - if (g_Options->GetSaveQueue() && g_Options->GetServerMode()) + if (g_Options->GetServerMode()) { // free up memory used by articles if possible fileInfo->GetArticles()->clear(); @@ -1408,7 +1408,7 @@ void QueueCoordinator::DiscardDirectRename(DownloadQueue* downloadQueue, NzbInfo } } - if (g_Options->GetSaveQueue() && g_Options->GetServerMode() && + if (g_Options->GetServerMode() && !fileInfo->GetArticles()->empty() && g_Options->GetContinuePartial() && fileInfo->GetActiveDownloads() == 0 && fileInfo->GetCachedArticles() == 0) { diff --git a/tests/queue/NzbFileTest.cpp b/tests/queue/NzbFileTest.cpp index ad1f53da..6288a98e 100644 --- a/tests/queue/NzbFileTest.cpp +++ b/tests/queue/NzbFileTest.cpp @@ -64,7 +64,6 @@ void TestNzb(std::string testFilename) TEST_CASE("Nzb parser", "[NzbFile][TestData]") { Options::CmdOptList cmdOpts; - cmdOpts.push_back("SaveQueue=no"); Options options(&cmdOpts, nullptr); TestNzb("dotless");