aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/notmuch-private.h
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2010-06-04 10:16:53 -0700
committerGravatar Carl Worth <cworth@cworth.org>2010-06-04 10:16:53 -0700
commit98845fdbb2a4acaa0036f8e2e998e726b18e6b13 (patch)
treed74a31c55be0f83ff36d773f3dc305d666818a9b /lib/notmuch-private.h
parent361b9d4bd9042629e3729b43d18a862ddc716242 (diff)
Avoid database corruption by not adding partially-constructed mail documents.
Previously we were using Xapian's add_document to allocate document ID values for notmuch_message_t objects. This had the drawback of adding a partially constructed mail document to the database. If notmuch was subsequently interrupted before fully populating this document, then later runs would be quite confused when seeing the partial documents. There are reports from the wild of people hitting internal errors of the form "Message ... has no thread ID" for example, (which is currently an unrecoverable error). We fix this by manually allocating document IDs without adding documents. With this change, we never call Xapian's add_document method, but only replace_document with either the current document ID of a message or a new one that we have allocated.
Diffstat (limited to 'lib/notmuch-private.h')
-rw-r--r--lib/notmuch-private.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index 3768d6f8..f9774a48 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -167,6 +167,9 @@ _notmuch_database_split_path (void *ctx,
const char *
_notmuch_database_get_directory_db_path (const char *path);
+unsigned int
+_notmuch_database_generate_doc_id (notmuch_database_t *notmuch);
+
notmuch_private_status_t
_notmuch_database_find_unique_doc_id (notmuch_database_t *notmuch,
const char *prefix_name,