]> git.notmuchmail.org Git - notmuch/blobdiff - lib/message.cc
notmuch_message_get_filename: Support old-style filename storage.
[notmuch] / lib / message.cc
index 82e8fce7edca3953a6503b5d2f5e7e76208c5200..0fc54668cb9a362454551d8880bade40b7c6583e 100644 (file)
@@ -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;