From 358223a6b192d3d336ee0a460a0fdbe408c52e5c Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 27 Jun 2015 21:08:24 -0400 Subject: [PATCH] Filter: Corrected implementation of ::safety --- src/Filter.cpp | 23 ++++++++++------------- src/Filter.h | 2 +- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/Filter.cpp b/src/Filter.cpp index c2221f6a2..c64d64f11 100644 --- a/src/Filter.cpp +++ b/src/Filter.cpp @@ -182,7 +182,7 @@ void Filter::subset (std::vector & output, bool applyContext /* = true */) } else { - safety (precompiled.size ()); + safety (); context.timer_filter.stop (); for (auto& task : context.tdb2.pending.get_tasks ()) @@ -261,7 +261,7 @@ bool Filter::pendingOnly () //////////////////////////////////////////////////////////////////////////////// // Disaster avoidance mechanism. If a WRITECMD has no filter, then it can cause // all tasks to be modified. This is usually not intended. -void Filter::safety (unsigned int terms) +void Filter::safety () { for (auto& a : context.cli2._args) { @@ -269,19 +269,16 @@ void Filter::safety (unsigned int terms) { if (a.hasTag ("WRITECMD")) { - if (terms) - { - if (! context.config.getBoolean ("allow.empty.filter")) - throw std::string (STRING_TASK_SAFETY_ALLOW); + if (! context.config.getBoolean ("allow.empty.filter")) + throw std::string (STRING_TASK_SAFETY_ALLOW); - // If user is willing to be asked, this can be avoided. - if (context.config.getBoolean ("confirmation") && - confirm (STRING_TASK_SAFETY_VALVE)) - return; + // If user is willing to be asked, this can be avoided. + if (context.config.getBoolean ("confirmation") && + confirm (STRING_TASK_SAFETY_VALVE)) + return; - // Sounds the alarm. - throw std::string (STRING_TASK_SAFETY_FAIL); - } + // Sounds the alarm. + throw std::string (STRING_TASK_SAFETY_FAIL); } // CMD was found. diff --git a/src/Filter.h b/src/Filter.h index 194f40dc9..e2c4c3d44 100644 --- a/src/Filter.h +++ b/src/Filter.h @@ -43,7 +43,7 @@ public: void subset (const std::vector &, std::vector &, bool applyContext = true); void subset (std::vector &, bool applyContext = true); bool pendingOnly (); - void safety (unsigned int); + void safety (); private: int _startCount;