aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/message.cc
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2010-01-07 09:22:34 -0800
committerGravatar Carl Worth <cworth@cworth.org>2010-01-07 09:22:34 -0800
commita274848f95e3eb074b48d14cf22774c75b80c735 (patch)
treec4a072526098cfd4641d74b7ab63ce95729b63d3 /lib/message.cc
parent1a38cb841ca4ce87f6b57f9b1baf1a5f8b8e35b7 (diff)
notmuch_message_get_filename: Support old-style filename storage.
When a notmuch database is upgraded to the new database format, (to support file rename and deletion), any message documents corresponding to deleted files will not currently be upgraded. This means that a search matching these documents will find no filenames in the expected place. Go ahead and return the filename as originally stored, (rather than aborting with an internal error), in this case.
Diffstat (limited to 'lib/message.cc')
-rw-r--r--lib/message.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/message.cc b/lib/message.cc
index 82e8fce7..0fc54668 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -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;