mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-21 18:38:08 +01:00
database: Allowing storing multiple filenames for a single message ID.
The library interface is unchanged so far, (still just notmuch_database_add_message), but internally, the old _set_filename function is now _add_filename instead.
This commit is contained in:
parent
6ca6c089e9
commit
1376a90db6
4 changed files with 23 additions and 20 deletions
|
@ -843,7 +843,6 @@ notmuch_database_get_directory_mtime (notmuch_database_t *notmuch,
|
|||
notmuch_private_status_t status;
|
||||
const char *db_path = NULL;
|
||||
time_t ret = 0;
|
||||
void *local = talloc_new (notmuch);
|
||||
|
||||
db_path = directory_db_path (path);
|
||||
|
||||
|
@ -1188,24 +1187,25 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
|
|||
goto DONE;
|
||||
}
|
||||
|
||||
_notmuch_message_add_filename (message, filename);
|
||||
|
||||
/* Is this a newly created message object? */
|
||||
if (private_status == NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND) {
|
||||
_notmuch_message_set_filename (message, filename);
|
||||
_notmuch_message_add_term (message, "type", "mail");
|
||||
|
||||
ret = _notmuch_database_link_message (notmuch, message,
|
||||
message_file);
|
||||
if (ret)
|
||||
goto DONE;
|
||||
|
||||
date = notmuch_message_file_get_header (message_file, "date");
|
||||
_notmuch_message_set_date (message, date);
|
||||
|
||||
_notmuch_message_index_file (message, filename);
|
||||
} else {
|
||||
ret = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID;
|
||||
goto DONE;
|
||||
}
|
||||
|
||||
ret = _notmuch_database_link_message (notmuch, message, message_file);
|
||||
if (ret)
|
||||
goto DONE;
|
||||
|
||||
date = notmuch_message_file_get_header (message_file, "date");
|
||||
_notmuch_message_set_date (message, date);
|
||||
|
||||
_notmuch_message_index_file (message, filename);
|
||||
|
||||
_notmuch_message_sync (message);
|
||||
} catch (const Xapian::Error &error) {
|
||||
fprintf (stderr, "A Xapian exception occurred adding message: %s.\n",
|
||||
|
|
|
@ -385,15 +385,12 @@ notmuch_message_get_replies (notmuch_message_t *message)
|
|||
return _notmuch_messages_create (message->replies);
|
||||
}
|
||||
|
||||
/* Set the filename for 'message' to 'filename'.
|
||||
*
|
||||
* XXX: We should still figure out if we think it's important to store
|
||||
* multiple filenames for email messages with identical message IDs.
|
||||
/* Add an additional 'filename' for 'message'.
|
||||
*
|
||||
* This change will not be reflected in the database until the next
|
||||
* call to _notmuch_message_set_sync. */
|
||||
notmuch_status_t
|
||||
_notmuch_message_set_filename (notmuch_message_t *message,
|
||||
_notmuch_message_add_filename (notmuch_message_t *message,
|
||||
const char *filename)
|
||||
{
|
||||
const char *relative, *directory, *basename;
|
||||
|
|
|
@ -211,7 +211,7 @@ _notmuch_message_gen_terms (notmuch_message_t *message,
|
|||
const char *text);
|
||||
|
||||
notmuch_status_t
|
||||
_notmuch_message_set_filename (notmuch_message_t *message,
|
||||
_notmuch_message_add_filename (notmuch_message_t *message,
|
||||
const char *filename);
|
||||
|
||||
void
|
||||
|
|
|
@ -698,14 +698,20 @@ notmuch_message_get_thread_id (notmuch_message_t *message);
|
|||
notmuch_messages_t *
|
||||
notmuch_message_get_replies (notmuch_message_t *message);
|
||||
|
||||
/* Get the filename for the email corresponding to 'message'.
|
||||
/* Get a filename for the email corresponding to 'message'.
|
||||
*
|
||||
* The returned filename is an absolute filename, (the initial
|
||||
* component will match notmuch_database_get_path() ).
|
||||
*
|
||||
* The returned string belongs to the message so should not be
|
||||
* modified or freed by the caller (nor should it be referenced after
|
||||
* the message is destroyed). */
|
||||
* the message is destroyed).
|
||||
*
|
||||
* Note: If this message corresponds to multiple files in the mail
|
||||
* store, (that is, multiple files contain identical message IDs),
|
||||
* this function will arbitrarily return a single one of those
|
||||
* filenames.
|
||||
*/
|
||||
const char *
|
||||
notmuch_message_get_filename (notmuch_message_t *message);
|
||||
|
||||
|
|
Loading…
Reference in a new issue