aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/notmuch-private.h
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2010-06-04 12:39:36 -0700
committerGravatar Carl Worth <cworth@cworth.org>2010-06-04 13:35:07 -0700
commit7b78eb4af6e87532795d09bd82152002ab4a74b1 (patch)
treeeb2ccea430a8162698787489dce2c4703f9b0f55 /lib/notmuch-private.h
parent77ab73834325f2b2a8870204af60e116d4209f12 (diff)
Add support (and tests) for messages with really long message IDs.
Scott Henson reported an internal error that occurred when he tried to add a message that referenced another message with a message ID well over 300 characters in length. The bug here was running into a Xapian limit for the length of metadata key names, (which is even more restrictive than the Xapian limit for the length of terms). We fix this by noticing long message ID values and instead using a message ID of the form "notmuch-sha1-<sha1_sum_of_message_id>". That is, we use SHA1 to generate a compressed, (but still unique), version of the message ID. We add support to the test suite to exercise this fix. The tests add a message referencing the long message ID, then add the message with the long message ID, then finally add another message referencing the long ID. Each of these tests exercise different code paths where the special handling is implemented. A final test ensures that all three messages are stitched together into a single thread---guaranteeing that the three code paths all act consistently.
Diffstat (limited to 'lib/notmuch-private.h')
-rw-r--r--lib/notmuch-private.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index f9774a48..5a0cf925 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -108,6 +108,16 @@ typedef enum {
* programmatically. */
#define NOTMUCH_TERM_MAX 245
+#define NOTMUCH_METADATA_THREAD_ID_PREFIX "thread_id_"
+
+/* For message IDs we have to be even more restrictive. Beyond fitting
+ * into the term limit, we also use message IDs to construct
+ * metadata-key values. And the documentation says that these should
+ * be restricted to about 200 characters. (The actual limit for the
+ * chert backend at least is 252.)
+ */
+#define NOTMUCH_MESSAGE_ID_MAX (200 - sizeof (NOTMUCH_METADATA_THREAD_ID_PREFIX))
+
typedef enum _notmuch_private_status {
/* First, copy all the public status values. */
NOTMUCH_PRIVATE_STATUS_SUCCESS = NOTMUCH_STATUS_SUCCESS,