mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-24 20:08:10 +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;
|
notmuch_private_status_t status;
|
||||||
const char *db_path = NULL;
|
const char *db_path = NULL;
|
||||||
time_t ret = 0;
|
time_t ret = 0;
|
||||||
void *local = talloc_new (notmuch);
|
|
||||||
|
|
||||||
db_path = directory_db_path (path);
|
db_path = directory_db_path (path);
|
||||||
|
|
||||||
|
@ -1188,24 +1187,25 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
|
||||||
goto DONE;
|
goto DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_notmuch_message_add_filename (message, filename);
|
||||||
|
|
||||||
/* Is this a newly created message object? */
|
/* Is this a newly created message object? */
|
||||||
if (private_status == NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND) {
|
if (private_status == NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND) {
|
||||||
_notmuch_message_set_filename (message, filename);
|
|
||||||
_notmuch_message_add_term (message, "type", "mail");
|
_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 {
|
} else {
|
||||||
ret = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID;
|
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);
|
_notmuch_message_sync (message);
|
||||||
} catch (const Xapian::Error &error) {
|
} catch (const Xapian::Error &error) {
|
||||||
fprintf (stderr, "A Xapian exception occurred adding message: %s.\n",
|
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);
|
return _notmuch_messages_create (message->replies);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the filename for 'message' to 'filename'.
|
/* Add an additional 'filename' for 'message'.
|
||||||
*
|
|
||||||
* XXX: We should still figure out if we think it's important to store
|
|
||||||
* multiple filenames for email messages with identical message IDs.
|
|
||||||
*
|
*
|
||||||
* This change will not be reflected in the database until the next
|
* This change will not be reflected in the database until the next
|
||||||
* call to _notmuch_message_set_sync. */
|
* call to _notmuch_message_set_sync. */
|
||||||
notmuch_status_t
|
notmuch_status_t
|
||||||
_notmuch_message_set_filename (notmuch_message_t *message,
|
_notmuch_message_add_filename (notmuch_message_t *message,
|
||||||
const char *filename)
|
const char *filename)
|
||||||
{
|
{
|
||||||
const char *relative, *directory, *basename;
|
const char *relative, *directory, *basename;
|
||||||
|
|
|
@ -211,7 +211,7 @@ _notmuch_message_gen_terms (notmuch_message_t *message,
|
||||||
const char *text);
|
const char *text);
|
||||||
|
|
||||||
notmuch_status_t
|
notmuch_status_t
|
||||||
_notmuch_message_set_filename (notmuch_message_t *message,
|
_notmuch_message_add_filename (notmuch_message_t *message,
|
||||||
const char *filename);
|
const char *filename);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -698,14 +698,20 @@ notmuch_message_get_thread_id (notmuch_message_t *message);
|
||||||
notmuch_messages_t *
|
notmuch_messages_t *
|
||||||
notmuch_message_get_replies (notmuch_message_t *message);
|
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
|
* The returned filename is an absolute filename, (the initial
|
||||||
* component will match notmuch_database_get_path() ).
|
* component will match notmuch_database_get_path() ).
|
||||||
*
|
*
|
||||||
* The returned string belongs to the message so should not be
|
* The returned string belongs to the message so should not be
|
||||||
* modified or freed by the caller (nor should it be referenced after
|
* 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 *
|
const char *
|
||||||
notmuch_message_get_filename (notmuch_message_t *message);
|
notmuch_message_get_filename (notmuch_message_t *message);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue