[PATCH 2/2] Add notmuch_database_reopen method
Adrien Bustany
adrien at bustany.org
Wed Oct 17 14:52:22 PDT 2012
Calling notmuch_database_reopen is needed to refresh the database
contents when the database on disk was modified by another
notmuch_database_t instance, for example in a different thread.
---
lib/database.cc | 17 +++++++++++++++++
lib/notmuch.h | 8 ++++++++
2 files changed, 25 insertions(+)
diff --git a/lib/database.cc b/lib/database.cc
index 1b680ab..f27d57f 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -763,6 +763,23 @@ notmuch_database_flush(notmuch_database_t *notmuch)
return status;
}
+notmuch_status_t
+notmuch_database_reopen(notmuch_database_t *notmuch)
+{
+ notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;
+
+ try {
+ if (notmuch->xapian_db != NULL)
+ (notmuch->xapian_db)->reopen ();
+ } catch (const Xapian::Error &error) {
+ fprintf(stderr, "A Xapian exception occured reopening the database: %s\n",
+ error.get_msg().c_str());
+ status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ }
+
+ return status;
+}
+
void
notmuch_database_close (notmuch_database_t *notmuch)
{
diff --git a/lib/notmuch.h b/lib/notmuch.h
index aef5c56..51d6a9a 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -205,6 +205,14 @@ notmuch_database_open (const char *path,
notmuch_status_t
notmuch_database_flush (notmuch_database_t *database);
+/* Refresh the database contents to the latest version.
+ *
+ * This is needed only if another instance of notmuch_database_t has
+ * modified the database contents on disk.
+ */
+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
--
1.7.11.7
More information about the notmuch
mailing list