mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
CmdPurge: Simplify implementation
This commit is contained in:
parent
c04bdc48aa
commit
3e65c3af5e
2 changed files with 17 additions and 7 deletions
|
@ -51,6 +51,16 @@ CmdPurge::CmdPurge ()
|
||||||
_category = Command::Category::operation;
|
_category = Command::Category::operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Purges the task, while taking care of:
|
||||||
|
// - dependencies on this task
|
||||||
|
void CmdPurge::purgeTask (Task& task, int& count)
|
||||||
|
{
|
||||||
|
context.tdb2.purge (task);
|
||||||
|
handleDeps (task);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Makes sure that any task having the dependency on the task being purged
|
// Makes sure that any task having the dependency on the task being purged
|
||||||
// has that dependency removed, to preserve referential integrity.
|
// has that dependency removed, to preserve referential integrity.
|
||||||
|
@ -89,8 +99,11 @@ int CmdPurge::execute (std::string&)
|
||||||
|
|
||||||
for (auto& task : filtered)
|
for (auto& task : filtered)
|
||||||
{
|
{
|
||||||
std::string uuid = task.get ("uuid");
|
// Allow purging of deleted tasks only. Hence no need to deal with:
|
||||||
|
// - unblocked tasks notifications (deleted tasks are not blocking)
|
||||||
|
// - project changes (deleted tasks not included in progress)
|
||||||
|
// It also has the nice property of being explicit - users need to
|
||||||
|
// mark tasks as deleted before purging.
|
||||||
if (task.getStatus () == Task::deleted)
|
if (task.getStatus () == Task::deleted)
|
||||||
{
|
{
|
||||||
std::string question;
|
std::string question;
|
||||||
|
@ -99,11 +112,7 @@ int CmdPurge::execute (std::string&)
|
||||||
task.get ("description"));
|
task.get ("description"));
|
||||||
|
|
||||||
if (permission (question, filtered.size ()))
|
if (permission (question, filtered.size ()))
|
||||||
{
|
purgeTask (task, count);
|
||||||
context.tdb2.purge (task);
|
|
||||||
handleDeps(task);
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
class CmdPurge : public Command
|
class CmdPurge : public Command
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
void purgeTask (Task& task, int& count);
|
||||||
void handleDeps (Task& task);
|
void handleDeps (Task& task);
|
||||||
public:
|
public:
|
||||||
CmdPurge ();
|
CmdPurge ();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue