Now _notmuch_database_filename_to_direntry takes a flags argument and
can indicate if the necessary directory documents do not exist.
Again, callers have been updated, but retain their original behavior.
* database path), return a new string (with 'ctx' as the talloc
* owner) suitable for use as a direntry term value.
*
* database path), return a new string (with 'ctx' as the talloc
* owner) suitable for use as a direntry term value.
*
- * The necessary directory documents will be created in the database
- * as needed.
+ * If (flags & NOTMUCH_FIND_CREATE), the necessary directory documents
+ * will be created in the database as needed. Otherwise, if the
+ * necessary directory documents do not exist, this sets
+ * *direntry to NULL and returns NOTMUCH_STATUS_SUCCESS.
*/
notmuch_status_t
_notmuch_database_filename_to_direntry (void *ctx,
notmuch_database_t *notmuch,
const char *filename,
*/
notmuch_status_t
_notmuch_database_filename_to_direntry (void *ctx,
notmuch_database_t *notmuch,
const char *filename,
+ notmuch_find_flags_t flags,
char **direntry)
{
const char *relative, *directory, *basename;
char **direntry)
{
const char *relative, *directory, *basename;
if (status)
return status;
if (status)
return status;
- status = _notmuch_database_find_directory_id (notmuch, directory, NOTMUCH_FIND_CREATE,
+ status = _notmuch_database_find_directory_id (notmuch, directory, flags,
+ if (status || directory_id == (unsigned int)-1) {
+ *direntry = NULL;
*direntry = talloc_asprintf (ctx, "%u:%s", directory_id, basename);
*direntry = talloc_asprintf (ctx, "%u:%s", directory_id, basename);
local = talloc_new (notmuch);
try {
local = talloc_new (notmuch);
try {
- status = _notmuch_database_filename_to_direntry (local, notmuch,
- filename, &direntry);
+ status = _notmuch_database_filename_to_direntry (
+ local, notmuch, filename, NOTMUCH_FIND_CREATE, &direntry);
if (status)
return status;
if (status)
return status;
- status = _notmuch_database_filename_to_direntry (local,
- message->notmuch,
- filename, &direntry);
+ status = _notmuch_database_filename_to_direntry (
+ local, message->notmuch, filename, NOTMUCH_FIND_CREATE, &direntry);
if (status)
return status;
if (status)
return status;
notmuch_status_t status;
Xapian::TermIterator i, last;
notmuch_status_t status;
Xapian::TermIterator i, last;
- status = _notmuch_database_filename_to_direntry (local, message->notmuch,
- filename, &direntry);
+ status = _notmuch_database_filename_to_direntry (
+ local, message->notmuch, filename, NOTMUCH_FIND_CREATE, &direntry);
if (status)
return status;
if (status)
return status;
_notmuch_database_filename_to_direntry (void *ctx,
notmuch_database_t *notmuch,
const char *filename,
_notmuch_database_filename_to_direntry (void *ctx,
notmuch_database_t *notmuch,
const char *filename,
+ notmuch_find_flags_t flags,
char **direntry);
/* directory.cc */
char **direntry);
/* directory.cc */