X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fmessage.cc;h=0fc54668cb9a362454551d8880bade40b7c6583e;hp=bd1795195b361409b918dc5ffdb7ecdc4c1666f8;hb=a274848f95e3eb074b48d14cf22774c75b80c735;hpb=498edff50373785c9dcc889d0fb6bc9bfc13dfcb diff --git a/lib/message.cc b/lib/message.cc index bd179519..0fc54668 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -411,7 +411,7 @@ _notmuch_message_add_filename (notmuch_message_t *message, if (status) return status; - _notmuch_message_add_term (message, "direntry", direntry); + _notmuch_message_add_term (message, "file-direntry", direntry); talloc_free (local); @@ -421,7 +421,7 @@ _notmuch_message_add_filename (notmuch_message_t *message, const char * notmuch_message_get_filename (notmuch_message_t *message) { - const char *prefix = _find_prefix ("direntry"); + const char *prefix = _find_prefix ("file-direntry"); int prefix_len = strlen (prefix); Xapian::TermIterator i; char *direntry, *colon; @@ -441,7 +441,19 @@ notmuch_message_get_filename (notmuch_message_t *message) if (i == message->doc.termlist_end () || strncmp (direntry, prefix, prefix_len)) { - INTERNAL_ERROR ("message with no filename"); + /* A message document created by an old version of notmuch + * (prior to rename support) will have the filename in the + * data of the document rather than as a file-direntry term. */ + const char *data; + + data = message->doc.get_data ().c_str (); + + if (data == NULL) + INTERNAL_ERROR ("message with no filename"); + + message->filename = talloc_strdup (message, data); + + return message->filename; } direntry += prefix_len;