From 82100a587314930f3d66e8df917108123dfad022 Mon Sep 17 00:00:00 2001 From: Adrien Bustany Date: Thu, 18 Oct 2012 00:52:21 +0300 Subject: [PATCH] [PATCH 1/2] Add notmuch_database_flush method --- 20/44071cbad4a56f45f76baccda96aebb2fb4e29 | 103 ++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 20/44071cbad4a56f45f76baccda96aebb2fb4e29 diff --git a/20/44071cbad4a56f45f76baccda96aebb2fb4e29 b/20/44071cbad4a56f45f76baccda96aebb2fb4e29 new file mode 100644 index 000000000..b616df1c7 --- /dev/null +++ b/20/44071cbad4a56f45f76baccda96aebb2fb4e29 @@ -0,0 +1,103 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 99B1E431FBD + for ; Wed, 17 Oct 2012 14:52:38 -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 klkh5PQPuAvZ for ; + Wed, 17 Oct 2012 14:52:38 -0700 (PDT) +Received: from mail.bustany.org (bustany.org [176.31.244.208]) + by olra.theworths.org (Postfix) with ESMTP id 29137431FB6 + 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 736F5140209 + for ; Wed, 17 Oct 2012 23:56:25 +0200 (CEST) +From: Adrien Bustany +To: notmuch@notmuchmail.org +Subject: [PATCH 1/2] Add notmuch_database_flush method +Date: Thu, 18 Oct 2012 00:52:21 +0300 +Message-Id: <1350510742-13447-2-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:38 -0000 + +This method explicitly flushes the pending modifications to disk. It is +useful if your program has various threads, each with a read only DB and +one writer thread with a read/write DB. In that case, you most likely +want the writer to sync the changes to disk so that the readers can see +them, without having to close and reopen the database completely. +--- + lib/database.cc | 18 ++++++++++++++++++ + lib/notmuch.h | 4 ++++ + 2 files changed, 22 insertions(+) + +diff --git a/lib/database.cc b/lib/database.cc +index 761dc1a..1b680ab 100644 +--- a/lib/database.cc ++++ b/lib/database.cc +@@ -745,6 +745,24 @@ notmuch_database_open (const char *path, + return status; + } + ++notmuch_status_t ++notmuch_database_flush(notmuch_database_t *notmuch) ++{ ++ notmuch_status_t status = NOTMUCH_STATUS_SUCCESS; ++ ++ try { ++ if (notmuch->xapian_db != NULL && ++ notmuch->mode == NOTMUCH_DATABASE_MODE_READ_WRITE) ++ (static_cast (notmuch->xapian_db))->flush (); ++ } catch (const Xapian::Error &error) { ++ fprintf(stderr, "A Xapian exception occured flushing 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 3633bed..aef5c56 100644 +--- a/lib/notmuch.h ++++ b/lib/notmuch.h +@@ -201,6 +201,10 @@ notmuch_database_open (const char *path, + notmuch_database_mode_t mode, + notmuch_database_t **database); + ++/* Flushes all the pending modifications to the database to disk. */ ++notmuch_status_t ++notmuch_database_flush (notmuch_database_t *database); ++ + /* Close the given notmuch database. + * + * After notmuch_database_close has been called, calls to other +-- +1.7.11.7 + -- 2.26.2