aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/message.cc
diff options
context:
space:
mode:
authorGravatar Austin Clements <amdragon@mit.edu>2014-10-06 17:17:07 -0600
committerGravatar David Bremner <david@tethera.net>2014-10-11 07:09:54 +0200
commit54ec8a0fd87ae7a32c8208be67a345c0eeea7f69 (patch)
treedd3ad3869bff03bab4dae8e58ea8e7f7bfa25fe1 /lib/message.cc
parent1c3b8fba226b4626212a37b503d9ebae3314edf4 (diff)
lib: Move message ID compression to _notmuch_message_create_for_message_id
Previously, this was performed by notmuch_database_add_message. This happens to be the only caller currently (which is why this was safe), but we're about to introduce more callers, and it makes more sense to put responsibility for ID compression in the lower-level function rather than requiring each caller to handle it.
Diffstat (limited to 'lib/message.cc')
-rw-r--r--lib/message.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/message.cc b/lib/message.cc
index 7e825480..bbfc2500 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -226,6 +226,10 @@ _notmuch_message_create_for_message_id (notmuch_database_t *notmuch,
else if (*status_ret)
return NULL;
+ /* If the message ID is too long, substitute its sha1 instead. */
+ if (strlen (message_id) > NOTMUCH_MESSAGE_ID_MAX)
+ message_id = _notmuch_message_id_compressed (message, message_id);
+
term = talloc_asprintf (NULL, "%s%s",
_find_prefix ("id"), message_id);
if (term == NULL) {