From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 13071431FAE for ; Thu, 19 Jul 2012 11:43:31 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XwhKJyHnmNW6 for ; Thu, 19 Jul 2012 11:43:30 -0700 (PDT) Received: from mail.bustany.org (bustany.org [176.31.244.208]) by olra.theworths.org (Postfix) with ESMTP id 6F3C5431FC2 for ; Thu, 19 Jul 2012 11:43:27 -0700 (PDT) Received: from localhost.localdomain (91-158-2-79.elisa-laajakaista.fi [91.158.2.79]) by mail.bustany.org (Postfix) with ESMTPSA id 53DFF1400C4 for ; Thu, 19 Jul 2012 20:45:56 +0200 (CEST) From: Adrien Bustany To: notmuch@notmuchmail.org Subject: [PATCH 2/2] Add notmuch_database_reopen method Date: Thu, 19 Jul 2012 21:43:21 +0300 Message-Id: <1342723401-26103-3-git-send-email-adrien@bustany.org> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1342723401-26103-1-git-send-email-adrien@bustany.org> References: <1342723401-26103-1-git-send-email-adrien@bustany.org> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Jul 2012 18:43:31 -0000 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(+), 0 deletions(-) diff --git a/lib/database.cc b/lib/database.cc index 55bcd17..3be5a30 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.7.6