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);
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");
- } else {
- ret = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID;
- goto DONE;
- }
- ret = _notmuch_database_link_message (notmuch, message, message_file);
- if (ret)
- 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);
+ date = notmuch_message_file_get_header (message_file, "date");
+ _notmuch_message_set_date (message, date);
- _notmuch_message_index_file (message, filename);
+ _notmuch_message_index_file (message, filename);
+ } else {
+ ret = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID;
+ }
_notmuch_message_sync (message);
} catch (const Xapian::Error &error) {
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;
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
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);