Patch: Flush and Reopen
    Austin Clements 
    amdragon at mit.edu
       
    Fri Sep  9 16:40:10 PDT 2011
    
    
  
On Fri, Sep 9, 2011 at 1:55 PM, Martin Owens <doctormo at 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.
    
    
More information about the notmuch
mailing list