* add mu_util_xapian_is_locked and use it

This commit is contained in:
Dirk-Jan C. Binnema
2011-01-14 07:47:19 +02:00
parent 2e4a94d0d6
commit 91cbdd6b71
3 changed files with 34 additions and 1 deletions

View File

@ -140,3 +140,19 @@ mu_util_xapian_clear (const gchar *xpath)
return FALSE;
}
gboolean
mu_util_xapian_is_locked (const gchar *xpath)
{
g_return_val_if_fail (xpath, FALSE);
try {
Xapian::WritableDatabase db (xpath, Xapian::DB_OPEN);
} catch (const Xapian::DatabaseLockError& xer) {
return TRUE;
} catch (const Xapian::Error &xer) {
g_warning ("%s: error: %s", __FUNCTION__, xer.get_msg().c_str());
}
return FALSE;
}