diff options
author | Carl Worth <cworth@cworth.org> | 2009-12-21 15:09:56 -0800 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2010-01-06 10:32:05 -0800 |
commit | 498edff50373785c9dcc889d0fb6bc9bfc13dfcb (patch) | |
tree | 931b1b52f0b4f7ee2a336ef37a8558869640fcff /lib/message.cc | |
parent | 1376a90db622b71e0997fca52c50ccf34faeed22 (diff) |
database: Abstract _filename_to_direntry from _add_message
The code to map a filename to a direntry is something that we're going
to want in a future _remove_message function, so put it in a new
function _notmuch_database_filename_to_direntry .
Diffstat (limited to 'lib/message.cc')
-rw-r--r-- | lib/message.cc | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/lib/message.cc b/lib/message.cc index 7d586903..bd179519 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -393,11 +393,9 @@ notmuch_status_t _notmuch_message_add_filename (notmuch_message_t *message, const char *filename) { - const char *relative, *directory, *basename; - char *term; - Xapian::docid directory_id; notmuch_status_t status; void *local = talloc_new (message); + char *direntry; if (message->filename) { talloc_free (message->filename); @@ -407,22 +405,13 @@ _notmuch_message_add_filename (notmuch_message_t *message, if (filename == NULL) INTERNAL_ERROR ("Message filename cannot be NULL."); - relative = _notmuch_database_relative_path (message->notmuch, filename); - - status = _notmuch_database_split_path (local, relative, - &directory, &basename); + status = _notmuch_database_filename_to_direntry (local, + message->notmuch, + filename, &direntry); if (status) return status; - status = _notmuch_database_find_directory_id (message->notmuch, directory, - &directory_id); - if (status) - return status; - - term = talloc_asprintf (local, "%s%u:%s", - _find_prefix ("direntry"), directory_id, basename); - - message->doc.add_term (term); + _notmuch_message_add_term (message, "direntry", direntry); talloc_free (local); |