* <many>: (WIP) use ~/mu/xapian as the database with an embedded version tag

- add checks in the code to make sure the database is up to date,
    if not, warn the user.
This commit is contained in:
Dirk-Jan C. Binnema
2010-01-23 20:50:06 +02:00
parent d5aa4e92e0
commit 501ce008d3
15 changed files with 265 additions and 29 deletions

View File

@ -53,7 +53,7 @@ mu_store_xapian_new (const char* xpath)
try {
store = g_new0(MuStoreXapian,1);
store->_db = new Xapian::WritableDatabase
store->_db = new Xapian::WritableDatabase
(xpath, Xapian::DB_CREATE_OR_OPEN);
/* keep count of processed docs */
@ -66,15 +66,45 @@ mu_store_xapian_new (const char* xpath)
} MU_XAPIAN_CATCH_BLOCK;
try {
delete store->_db;
} MU_XAPIAN_CATCH_BLOCK;
try { delete store->_db; } MU_XAPIAN_CATCH_BLOCK;
g_free (store);
return NULL;
}
char*
mu_store_xapian_version (MuStoreXapian *store)
{
g_return_val_if_fail (store, NULL);
try {
const std::string version (
store->_db->get_metadata (MU_XAPIAN_VERSION_KEY));
return version.empty() ? NULL : g_strdup (version.c_str());
} MU_XAPIAN_CATCH_BLOCK;
return NULL;
}
gboolean
mu_store_xapian_set_version (MuStoreXapian *store, const char* version)
{
g_return_val_if_fail (store, FALSE);
g_return_val_if_fail (version, FALSE);
try {
store->_db->set_metadata (MU_XAPIAN_VERSION_KEY, version);
return TRUE;
} MU_XAPIAN_CATCH_BLOCK;
return FALSE;
}
static void
begin_trx_if (MuStoreXapian *store, gboolean cond)
{