mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-12-25 19:04:53 +01:00
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.
This commit is contained in:
parent
1a38cb841c
commit
a274848f95
1 changed files with 13 additions and 1 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue