unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Austin Clements <amdragon@mit.edu>
To: Martin Owens <doctormo@gmail.com>
Cc: Notmuch developer list <notmuch@notmuchmail.org>
Subject: Re: Patch: Flush and Reopen
Date: Fri, 9 Sep 2011 19:40:10 -0400	[thread overview]
Message-ID: <CAH-f9WtuL48RtaJ9njxHyCy5cqhhrxdz+30ydE11rq41Lu06pA@mail.gmail.com> (raw)
In-Reply-To: <1315590950.2435.59.camel@delen>

On Fri, Sep 9, 2011 at 1:55 PM, Martin Owens <doctormo@gmail.com> wrote:
> That probably was unintended. See attached for the all new slimmed down
> patch.


--- a/lib/database.cc
+++ b/lib/database.cc
@@ -700,18 +700,37 @@ notmuch_database_open (const char *path,
 }

 void
-notmuch_database_close (notmuch_database_t *notmuch)
+notmuch_database_reopen (notmuch_database_t *notmuch)
 {
     try {
-	if (notmuch->mode == NOTMUCH_DATABASE_MODE_READ_WRITE)
-	    (static_cast <Xapian::WritableDatabase *> (notmuch->xapian_db))->flush ();
+        if (notmuch->mode == NOTMUCH_DATABASE_MODE_READ_ONLY)
+            (static_cast <Xapian::Database *> (notmuch->xapian_db))->reopen();

I was thinking this should probably just be

try {
  notmuch->xapian_db->reopen ();
} catch ...

(indented correctly, of course).  Reopen is a method of
Xapian::Database, which is what notmuch->xapian_db is anyway (unlike,
flush, which is a member of the subclass WritableDatabase and hence
requires the cast).  And reopening is a sensible thing to do on both
read-only and read/write databases.

Also, in keeping with notmuch code style, you should use tabs for
indentation and put a space before the open paren argument lists.

  reply	other threads:[~2011-09-09 23:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-08  1:34 Patch: Flush and Reopen Martin Owens
2011-09-09  2:42 ` Austin Clements
2011-09-09  2:54   ` Martin Owens
2011-09-09 11:06     ` David Bremner
2011-09-09 17:55       ` Martin Owens
2011-09-09 23:40         ` Austin Clements [this message]
2011-09-10  0:43           ` Martin Owens
2011-09-12  0:23             ` Austin Clements
2011-09-12  1:03               ` Martin Owens
2011-09-12  1:04               ` Martin Owens
2011-09-12 12:23                 ` Sebastian Spaeth

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=CAH-f9WtuL48RtaJ9njxHyCy5cqhhrxdz+30ydE11rq41Lu06pA@mail.gmail.com \
    --to=amdragon@mit.edu \
    --cc=doctormo@gmail.com \
    --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).