diff options
author | Austin Clements <amdragon@MIT.EDU> | 2012-05-18 00:13:35 -0400 |
---|---|---|
committer | David Bremner <bremner@debian.org> | 2012-05-23 22:30:32 -0300 |
commit | 0c950146a14fa2bb0a0bf542073b2cdca141afd1 (patch) | |
tree | 2dcbc9faabb6cda485b05324041c0a5821c44ce6 /lib/database.cc | |
parent | f69314fbd37f403a395b7c1c44595c8f696b05b7 (diff) |
lib: Perform the same transformation to _notmuch_database_find_directory_id
Now _notmuch_database_find_directory_id takes a flags argument, which
it passes through to _notmuch_directory_create and can indicate if the
directory does not exist. Again, callers have been updated, but
retain their original behavior.
Diffstat (limited to 'lib/database.cc')
-rw-r--r-- | lib/database.cc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/database.cc b/lib/database.cc index df996a9a..716982d0 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -1197,9 +1197,17 @@ _notmuch_database_split_path (void *ctx, return NOTMUCH_STATUS_SUCCESS; } +/* Find the document ID of the specified directory. + * + * If (flags & NOTMUCH_FIND_CREATE), a new directory document will be + * created if one does not exist for 'path'. Otherwise, if the + * directory document does not exist, this sets *directory_id to + * ((unsigned int)-1) and returns NOTMUCH_STATUS_SUCCESS. + */ notmuch_status_t _notmuch_database_find_directory_id (notmuch_database_t *notmuch, const char *path, + notmuch_find_flags_t flags, unsigned int *directory_id) { notmuch_directory_t *directory; @@ -1210,8 +1218,8 @@ _notmuch_database_find_directory_id (notmuch_database_t *notmuch, return NOTMUCH_STATUS_SUCCESS; } - directory = _notmuch_directory_create (notmuch, path, NOTMUCH_FIND_CREATE, &status); - if (status) { + directory = _notmuch_directory_create (notmuch, path, flags, &status); + if (status || !directory) { *directory_id = -1; return status; } @@ -1260,7 +1268,7 @@ _notmuch_database_filename_to_direntry (void *ctx, if (status) return status; - status = _notmuch_database_find_directory_id (notmuch, directory, + status = _notmuch_database_find_directory_id (notmuch, directory, NOTMUCH_FIND_CREATE, &directory_id); if (status) return status; |