From 90340fe59d677c989352f08e82f908016c25fafa Mon Sep 17 00:00:00 2001 From: Gaute Hope Date: Mon, 11 Aug 2014 14:16:12 +0200 Subject: [PATCH] lib: expose XapianDatabae::reopen() through notmuch_database_reopen() --- lib/database.cc | 18 ++++++++++++++++++ lib/notmuch.h | 22 ++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/lib/database.cc b/lib/database.cc index c760290..80af410 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -778,6 +778,24 @@ notmuch_database_open (const char *path, } notmuch_status_t +notmuch_database_reopen (notmuch_database_t *notmuch) +{ + try { + notmuch->xapian_db->reopen (); + + return NOTMUCH_STATUS_SUCCESS; + + } catch (const Xapian::Error &error) { + if (! notmuch->exception_reported) { + fprintf (stderr, "Error: A Xapian exception occurred while reopening database: %s\n", + error.get_msg().c_str()); + } + + return NOTMUCH_STATUS_XAPIAN_EXCEPTION; + } +} + +notmuch_status_t notmuch_database_close (notmuch_database_t *notmuch) { notmuch_status_t status = NOTMUCH_STATUS_SUCCESS; diff --git a/lib/notmuch.h b/lib/notmuch.h index 3c5ec98..00950af 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -277,6 +277,28 @@ notmuch_database_open (const char *path, notmuch_database_t **database); /** + * Reopen the given notmuch database. + * + * The underlying Xapian database will be re-opened to the latest + * available version. It can be used to make sure the latest results + * are returned or to recover from an Xapaian::DatabaseModifiedError + * which can occur after external database modification. + * + * Calling notmuch_database_reopen on a database that has been closed + * will result in a NOTMUCH_STATUS_XAPAIAN_EXCEPTION. + * + * Return value: + * + * NOTMUCH_STATUS_SUCCESS: Successfully reopened database. + * + * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred. + * + */ +notmuch_status_t +notmuch_database_reopen (notmuch_database_t *database); + + +/** * Close the given notmuch database. * * After notmuch_database_close has been called, calls to other -- 2.0.3