aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--lib/database.cc24
-rw-r--r--lib/message.cc7
-rw-r--r--lib/notmuch-private.h2
-rw-r--r--lib/notmuch.h10
4 files changed, 23 insertions, 20 deletions
diff --git a/lib/database.cc b/lib/database.cc
index 7d09119c..553c9f82 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -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,23 +1187,24 @@ 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");
- } 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) {
diff --git a/lib/message.cc b/lib/message.cc
index 3f533423..7d586903 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -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;
diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index 5a930bb3..e9712832 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -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
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 786b8e9f..e96474f6 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -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);