]> git.notmuchmail.org Git - notmuch/blobdiff - lib/database.cc
lib: add _notmuch_database_reopen
[notmuch] / lib / database.cc
index 386dcd17adc4d0a91ab5eb10479907b254d32187..ba440d4db87e4608b043167860cc09e911f4aeda 100644 (file)
@@ -951,6 +951,7 @@ notmuch_database_open_verbose (const char *path,
 
     notmuch->mode = mode;
     notmuch->atomic_nesting = 0;
+    notmuch->view = 1;
     try {
        string last_thread_id;
        string last_mod;
@@ -1133,6 +1134,28 @@ notmuch_database_close (notmuch_database_t *notmuch)
     return status;
 }
 
+notmuch_status_t
+_notmuch_database_reopen (notmuch_database_t *notmuch)
+{
+    if (notmuch->mode != NOTMUCH_DATABASE_MODE_READ_ONLY)
+       return NOTMUCH_STATUS_UNSUPPORTED_OPERATION;
+
+    try {
+       notmuch->xapian_db->reopen ();
+    } catch (const Xapian::Error &error) {
+       if (! notmuch->exception_reported) {
+           _notmuch_database_log (notmuch, "Error: A Xapian exception reopening database: %s\n",
+                                  error.get_msg ().c_str ());
+           notmuch->exception_reported = TRUE;
+       }
+       return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+    }
+
+    notmuch->view++;
+
+    return NOTMUCH_STATUS_SUCCESS;
+}
+
 static int
 unlink_cb (const char *path,
           unused (const struct stat *sb),