unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Adrien Bustany <adrien@bustany.org>
To: notmuch@notmuchmail.org
Subject: [PATCH 2/2] Add notmuch_database_reopen method
Date: Thu, 18 Oct 2012 00:52:22 +0300	[thread overview]
Message-ID: <1350510742-13447-3-git-send-email-adrien@bustany.org> (raw)
In-Reply-To: <1350510742-13447-1-git-send-email-adrien@bustany.org>

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

  parent reply	other threads:[~2012-10-17 21:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-19 18:43 [PATCH 0/2] Add flush/reopen methods to notmuch_database_t Adrien Bustany
2012-07-19 18:43 ` [PATCH 1/2] Add notmuch_database_flush method Adrien Bustany
2012-10-17 15:53   ` Ethan Glasser-Camp
2012-10-17 21:34     ` Adrien Bustany
2012-07-19 18:43 ` [PATCH 2/2] Add notmuch_database_reopen method Adrien Bustany
2012-10-17 21:52 ` [PATCH v2 0/2] Add flush/reopen methods to notmuch_database_t Adrien Bustany
2012-10-17 21:52   ` [PATCH 1/2] Add notmuch_database_flush method Adrien Bustany
2012-10-17 21:52   ` Adrien Bustany [this message]
2012-10-19  3:19   ` [PATCH v2 0/2] Add flush/reopen methods to notmuch_database_t Ethan Glasser-Camp
2012-10-19  7:19   ` Jani Nikula
2012-10-20 15:49     ` Ethan Glasser-Camp
2012-10-25 18:39       ` Adrien Bustany
2012-12-12  1:40   ` Michael Forney
2012-12-27  3:23     ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1350510742-13447-3-git-send-email-adrien@bustany.org \
    --to=adrien@bustany.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).