Put begin transaction/end transaction into contructor/destructor of ObjectDb
diff --git a/src/object-db.cc b/src/object-db.cc
index 991aab4..6120dc0 100644
--- a/src/object-db.cc
+++ b/src/object-db.cc
@@ -34,7 +34,7 @@
namespace fs = boost::filesystem;
const std::string INIT_DATABASE = "\
-CREATE TABLE \n\
+CREATE TABLE \n \
File( \n\
device_name BLOB NOT NULL, \n\
segment INTEGER, \n\
@@ -68,6 +68,8 @@
// std::cerr << "DEBUG: " << errmsg << std::endl;
sqlite3_free (errmsg);
}
+
+ willStartSave ();
}
bool
@@ -110,6 +112,8 @@
ObjectDb::~ObjectDb ()
{
+ didStopSave ();
+
int res = sqlite3_close (m_db);
if (res != SQLITE_OK)
{
@@ -179,3 +183,15 @@
// return retval;
// }
+
+void
+ObjectDb::willStartSave ()
+{
+ sqlite3_exec (m_db, "BEGIN TRANSACTION;", 0,0,0);
+}
+
+void
+ObjectDb::didStopSave ()
+{
+ sqlite3_exec (m_db, "END TRANSACTION;", 0,0,0);
+}
diff --git a/src/object-db.h b/src/object-db.h
index 8591096..f60e504 100644
--- a/src/object-db.h
+++ b/src/object-db.h
@@ -47,7 +47,14 @@
static bool
DoesExist (const boost::filesystem::path &folder, const Ccnx::Name &deviceName, const std::string &hash);
-
+
+private:
+ void
+ willStartSave ();
+
+ void
+ didStopSave ();
+
private:
sqlite3 *m_db;
};