X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fdatabase.cc;h=ba440d4db87e4608b043167860cc09e911f4aeda;hp=8016c4df3d167c2c6fd30dbbe5e3ba66dd3fbffc;hb=5a69aa14748162429c43ad5ff3d8b35779fff0d4;hpb=9951598d11f9e883374d295f886009cdb64d8f63 diff --git a/lib/database.cc b/lib/database.cc index 8016c4df..ba440d4d 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -644,7 +644,7 @@ parse_references (void *ctx, ref = _parse_message_id (ctx, refs, &refs); if (ref && strcmp (ref, message_id)) { - g_hash_table_insert (hash, ref, NULL); + g_hash_table_add (hash, ref); last_ref = ref; } } @@ -653,7 +653,7 @@ parse_references (void *ctx, * reference to the database. We should avoid making a message * its own parent, thus the above check. */ - return last_ref; + return talloc_strdup(ctx, last_ref); } notmuch_status_t @@ -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),