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 06E6B431FC4 for ; Wed, 17 Oct 2012 14:52:40 -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 TdOMsd1PTqUk for ; Wed, 17 Oct 2012 14:52:39 -0700 (PDT) Received: from mail.bustany.org (bustany.org [176.31.244.208]) by olra.theworths.org (Postfix) with ESMTP id D48CC431FBD for ; Wed, 17 Oct 2012 14:52:38 -0700 (PDT) Received: from localhost.localdomain (91-158-5-86.elisa-laajakaista.fi [91.158.5.86]) by mail.bustany.org (Postfix) with ESMTPSA id 319321401ED for ; Wed, 17 Oct 2012 23:56:26 +0200 (CEST) From: Adrien Bustany To: notmuch@notmuchmail.org Subject: [PATCH 2/2] Add notmuch_database_reopen method Date: Thu, 18 Oct 2012 00:52:22 +0300 Message-Id: <1350510742-13447-3-git-send-email-adrien@bustany.org> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1350510742-13447-1-git-send-email-adrien@bustany.org> References: <1342723401-26103-1-git-send-email-adrien@bustany.org> <1350510742-13447-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: Wed, 17 Oct 2012 21:52:40 -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(+) 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