- Eliminated the now obsolete TDB code from Context.
- Added auto-commit code for commands that auto-gc.
This commit is contained in:
Paul Beckingham 2011-09-03 13:02:17 -04:00
parent 5d6f6e2073
commit 1b3ac82d7e
2 changed files with 10 additions and 10 deletions

View file

@ -51,7 +51,6 @@ Context::Context ()
, data_dir ()
, extension_dir ()
, config ()
, tdb ()
, tdb2 ()
, dom ()
, determine_color_use (true)
@ -150,8 +149,6 @@ int Context::initialize (int argc, const char** argv)
locale = locale.substr (0, period);
// Initialize the database.
tdb.clear (); // TODO Obsolete
tdb.location (data_dir); // TODO Obsolete
tdb2.set_location (data_dir);
// Hook system init, plus post-start event occurring at the first possible
@ -316,11 +313,13 @@ int Context::dispatch (std::string &out)
Command* c = commands[command];
// GC is invoked prior to running any command that displays task IDs.
if (c->displays_id ())
// GC is invoked prior to running any command that displays task IDs, if
// possible.
bool auto_commit = false;
if (c->displays_id () && !tdb2.read_only ())
{
tdb.gc ();
tdb2.gc ();
auto_commit = true;
}
// Only read-only commands can be run when TDB2 is read-only.
@ -330,7 +329,11 @@ int Context::dispatch (std::string &out)
throw std::string ("");
*/
return c->execute (out);
int rc = c->execute (out);
if (auto_commit)
tdb2.commit ();
return rc;
}
return commands["help"]->execute (out);
@ -557,7 +560,6 @@ void Context::decomposeSortField (
// be initialized. That makes this method something of a misnomer. So be it.
void Context::clear ()
{
tdb.clear (); // TODO Obsolete
tdb2.clear ();
a3.clear ();

View file

@ -32,7 +32,6 @@
#include <Column.h>
#include <Config.h>
#include <Task.h>
#include <TDB.h>
#include <TDB2.h>
#include <Hooks.h>
#include <DOM.h>
@ -89,7 +88,6 @@ public:
Directory extension_dir;
Config config;
TDB tdb; // TODO Obsolete
TDB2 tdb2;
std::map <std::string, std::string> aliases;
Hooks hooks;