mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
- TDB::gc now only calls overwritePending when something changed.
- Removed TDB::gc calls from report.cpp. - Made TDB::gc calls from task.cpp whenever necessary. - Disabled TDB::gc calls when running a report for the sake of the shadow file. - Shadow file overwrite now implemented using ostream, instead of cout.rdbuf trickery, for the well-being of cygwin.
This commit is contained in:
parent
b176591261
commit
2a5736b876
4 changed files with 42 additions and 51 deletions
|
@ -486,8 +486,11 @@ int TDB::gc ()
|
|||
}
|
||||
}
|
||||
|
||||
// Dump all clean tasks into pending.
|
||||
overwritePending (pending);
|
||||
// Dump all clean tasks into pending. But don't bother unless at least one
|
||||
// task was transferred.
|
||||
if (count)
|
||||
overwritePending (pending);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,6 @@ std::string handleList (TDB& tdb, T& task, Config& conf)
|
|||
#endif
|
||||
|
||||
// Get the pending tasks.
|
||||
tdb.gc ();
|
||||
std::vector <T> tasks;
|
||||
tdb.allPendingT (tasks);
|
||||
handleRecurrence (tdb, tasks);
|
||||
|
@ -278,7 +277,6 @@ std::string handleSmallList (TDB& tdb, T& task, Config& conf)
|
|||
#endif
|
||||
|
||||
// Get the pending tasks.
|
||||
tdb.gc ();
|
||||
std::vector <T> tasks;
|
||||
tdb.allPendingT (tasks);
|
||||
handleRecurrence (tdb, tasks);
|
||||
|
@ -410,7 +408,6 @@ std::string handleCompleted (TDB& tdb, T& task, Config& conf)
|
|||
#endif
|
||||
|
||||
// Get the pending tasks.
|
||||
tdb.gc ();
|
||||
std::vector <T> tasks;
|
||||
tdb.completedT (tasks);
|
||||
filter (tasks, task);
|
||||
|
@ -700,7 +697,6 @@ std::string handleLongList (TDB& tdb, T& task, Config& conf)
|
|||
#endif
|
||||
|
||||
// Get all the tasks.
|
||||
tdb.gc ();
|
||||
std::vector <T> tasks;
|
||||
tdb.allPendingT (tasks);
|
||||
handleRecurrence (tdb, tasks);
|
||||
|
@ -864,7 +860,6 @@ std::string handleReportSummary (TDB& tdb, T& task, Config& conf)
|
|||
std::stringstream out;
|
||||
|
||||
// Generate unique list of project names.
|
||||
tdb.gc ();
|
||||
std::map <std::string, bool> allProjects;
|
||||
std::vector <T> pending;
|
||||
tdb.allPendingT (pending);
|
||||
|
@ -1040,7 +1035,6 @@ std::string handleReportNext (TDB& tdb, T& task, Config& conf)
|
|||
std::stringstream out;
|
||||
|
||||
// Load all pending.
|
||||
tdb.gc ();
|
||||
std::vector <T> pending;
|
||||
tdb.allPendingT (pending);
|
||||
handleRecurrence (tdb, pending);
|
||||
|
@ -1061,8 +1055,6 @@ std::string handleReportNext (TDB& tdb, T& task, Config& conf)
|
|||
}
|
||||
#endif
|
||||
|
||||
tdb.gc ();
|
||||
|
||||
// Get the pending tasks.
|
||||
std::vector <T> tasks;
|
||||
tdb.pendingT (tasks);
|
||||
|
@ -1223,7 +1215,6 @@ std::string handleReportHistory (TDB& tdb, T& task, Config& conf)
|
|||
std::map <time_t, int> deletedGroup;
|
||||
|
||||
// Scan the pending tasks.
|
||||
tdb.gc ();
|
||||
std::vector <T> pending;
|
||||
tdb.allPendingT (pending);
|
||||
handleRecurrence (tdb, pending);
|
||||
|
@ -1423,7 +1414,6 @@ std::string handleReportGHistory (TDB& tdb, T& task, Config& conf)
|
|||
std::map <time_t, int> deletedGroup;
|
||||
|
||||
// Scan the pending tasks.
|
||||
tdb.gc ();
|
||||
std::vector <T> pending;
|
||||
tdb.allPendingT (pending);
|
||||
handleRecurrence (tdb, pending);
|
||||
|
@ -1837,7 +1827,6 @@ std::string handleReportCalendar (TDB& tdb, T& task, Config& conf)
|
|||
std::stringstream out;
|
||||
|
||||
// Load all the pending tasks.
|
||||
tdb.gc ();
|
||||
std::vector <T> pending;
|
||||
tdb.allPendingT (pending);
|
||||
handleRecurrence (tdb, pending);
|
||||
|
@ -1939,7 +1928,6 @@ std::string handleReportActive (TDB& tdb, T& task, Config& conf)
|
|||
#endif
|
||||
|
||||
// Get all the tasks.
|
||||
tdb.gc ();
|
||||
std::vector <T> tasks;
|
||||
tdb.pendingT (tasks);
|
||||
filter (tasks, task);
|
||||
|
@ -2174,7 +2162,6 @@ std::string handleReportOldest (TDB& tdb, T& task, Config& conf)
|
|||
#endif
|
||||
|
||||
// Get the pending tasks.
|
||||
tdb.gc ();
|
||||
std::vector <T> tasks;
|
||||
tdb.allPendingT (tasks);
|
||||
handleRecurrence (tdb, tasks);
|
||||
|
@ -2323,7 +2310,6 @@ std::string handleReportNewest (TDB& tdb, T& task, Config& conf)
|
|||
#endif
|
||||
|
||||
// Get the pending tasks.
|
||||
tdb.gc ();
|
||||
std::vector <T> tasks;
|
||||
tdb.allPendingT (tasks);
|
||||
handleRecurrence (tdb, tasks);
|
||||
|
|
68
src/task.cpp
68
src/task.cpp
|
@ -742,20 +742,22 @@ std::string runTaskCommand (
|
|||
int argc,
|
||||
char** argv,
|
||||
TDB& tdb,
|
||||
Config& conf)
|
||||
Config& conf,
|
||||
bool gc /* = true */)
|
||||
{
|
||||
std::vector <std::string> args;
|
||||
for (int i = 1; i < argc; ++i)
|
||||
args.push_back (argv[i]);
|
||||
|
||||
return runTaskCommand (args, tdb, conf);
|
||||
return runTaskCommand (args, tdb, conf, gc);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string runTaskCommand (
|
||||
std::vector <std::string>& args,
|
||||
TDB& tdb,
|
||||
Config& conf)
|
||||
Config& conf,
|
||||
bool gc /* = false */)
|
||||
{
|
||||
// If argc == 1 and the default.command configuration variable is set,
|
||||
// then use that, otherwise stick with argc/argv.
|
||||
|
@ -774,36 +776,36 @@ std::string runTaskCommand (
|
|||
|
||||
std::string out = "";
|
||||
|
||||
if (command == "add") handleAdd (tdb, task, conf);
|
||||
else if (command == "projects") out = handleProjects (tdb, task, conf);
|
||||
else if (command == "tags") out = handleTags (tdb, task, conf);
|
||||
else if (command == "list") out = handleList (tdb, task, conf);
|
||||
else if (command == "info") out = handleInfo (tdb, task, conf);
|
||||
else if (command == "undelete") out = handleUndelete (tdb, task, conf);
|
||||
else if (command == "long") out = handleLongList (tdb, task, conf);
|
||||
else if (command == "ls") out = handleSmallList (tdb, task, conf);
|
||||
else if (command == "colors") out = handleColor ( conf);
|
||||
else if (command == "completed") out = handleCompleted (tdb, task, conf);
|
||||
else if (command == "delete") out = handleDelete (tdb, task, conf);
|
||||
else if (command == "start") out = handleStart (tdb, task, conf);
|
||||
else if (command == "done") handleDone (tdb, task, conf);
|
||||
else if (command == "undo") out = handleUndo (tdb, task, conf);
|
||||
else if (command == "export") handleExport (tdb, task, conf);
|
||||
else if (command == "version") out = handleVersion ( conf);
|
||||
else if (command == "summary") out = handleReportSummary (tdb, task, conf);
|
||||
else if (command == "next") out = handleReportNext (tdb, task, conf);
|
||||
else if (command == "history") out = handleReportHistory (tdb, task, conf);
|
||||
else if (command == "ghistory") out = handleReportGHistory (tdb, task, conf);
|
||||
else if (command == "calendar") out = handleReportCalendar (tdb, task, conf);
|
||||
else if (command == "active") out = handleReportActive (tdb, task, conf);
|
||||
else if (command == "overdue") out = handleReportOverdue (tdb, task, conf);
|
||||
else if (command == "oldest") out = handleReportOldest (tdb, task, conf);
|
||||
else if (command == "newest") out = handleReportNewest (tdb, task, conf);
|
||||
else if (command == "stats") out = handleReportStats (tdb, task, conf);
|
||||
else if (command == "usage") out = handleReportUsage (tdb, task, conf);
|
||||
else if (command == "" && task.getId ()) handleModify (tdb, task, conf);
|
||||
else if (command == "help") longUsage (conf);
|
||||
else shortUsage (conf);
|
||||
if (command == "" && task.getId ()) { handleModify (tdb, task, conf); }
|
||||
else if (command == "add") { handleAdd (tdb, task, conf); }
|
||||
else if (command == "done") { handleDone (tdb, task, conf); }
|
||||
else if (command == "export") { handleExport (tdb, task, conf); }
|
||||
else if (command == "projects") { out = handleProjects (tdb, task, conf); }
|
||||
else if (command == "tags") { out = handleTags (tdb, task, conf); }
|
||||
else if (command == "info") { out = handleInfo (tdb, task, conf); }
|
||||
else if (command == "undelete") { out = handleUndelete (tdb, task, conf); }
|
||||
else if (command == "delete") { out = handleDelete (tdb, task, conf); }
|
||||
else if (command == "start") { out = handleStart (tdb, task, conf); }
|
||||
else if (command == "undo") { out = handleUndo (tdb, task, conf); }
|
||||
else if (command == "stats") { out = handleReportStats (tdb, task, conf); }
|
||||
else if (command == "usage") { out = handleReportUsage (tdb, task, conf); }
|
||||
else if (command == "list") { if (gc) tdb.gc (); out = handleList (tdb, task, conf); }
|
||||
else if (command == "long") { if (gc) tdb.gc (); out = handleLongList (tdb, task, conf); }
|
||||
else if (command == "ls") { if (gc) tdb.gc (); out = handleSmallList (tdb, task, conf); }
|
||||
else if (command == "completed") { if (gc) tdb.gc (); out = handleCompleted (tdb, task, conf); }
|
||||
else if (command == "summary") { if (gc) tdb.gc (); out = handleReportSummary (tdb, task, conf); }
|
||||
else if (command == "next") { if (gc) tdb.gc (); out = handleReportNext (tdb, task, conf); }
|
||||
else if (command == "history") { if (gc) tdb.gc (); out = handleReportHistory (tdb, task, conf); }
|
||||
else if (command == "ghistory") { if (gc) tdb.gc (); out = handleReportGHistory (tdb, task, conf); }
|
||||
else if (command == "calendar") { if (gc) tdb.gc (); out = handleReportCalendar (tdb, task, conf); }
|
||||
else if (command == "active") { if (gc) tdb.gc (); out = handleReportActive (tdb, task, conf); }
|
||||
else if (command == "overdue") { if (gc) tdb.gc (); out = handleReportOverdue (tdb, task, conf); }
|
||||
else if (command == "oldest") { if (gc) tdb.gc (); out = handleReportOldest (tdb, task, conf); }
|
||||
else if (command == "newest") { if (gc) tdb.gc (); out = handleReportNewest (tdb, task, conf); }
|
||||
else if (command == "colors") { out = handleColor ( conf); }
|
||||
else if (command == "version") { out = handleVersion ( conf); }
|
||||
else if (command == "help") { longUsage ( conf); }
|
||||
else { shortUsage ( conf); }
|
||||
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -67,8 +67,8 @@ bool generateDueDates (T&, std::vector <Date>&);
|
|||
Date getNextRecurrence (Date&, std::string&);
|
||||
void updateRecurrenceMask (TDB&, std::vector <T>&, T&);
|
||||
void onChangeCallback ();
|
||||
std::string runTaskCommand (int, char**, TDB&, Config&);
|
||||
std::string runTaskCommand (std::vector <std::string>&, TDB&, Config&);
|
||||
std::string runTaskCommand (int, char**, TDB&, Config&, bool gc = true);
|
||||
std::string runTaskCommand (std::vector <std::string>&, TDB&, Config&, bool gc = false);
|
||||
|
||||
// command.cpp
|
||||
void handleAdd (TDB&, T&, Config&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue