From f69314fbd37f403a395b7c1c44595c8f696b05b7 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Fri, 18 May 2012 00:13:34 -0400 Subject: lib: Make directory document creation optional for _notmuch_directory_create Previously this function would create directory documents if they didn't exist. As a result, it could only be used on writable databases. This adds an argument to make creation optional and to make this function work on read-only databases. We use a flag argument to avoid a bare boolean and to permit future expansion. Both callers have been updated, but currently retain the old behavior. We'll take advantage of the new argument in the following patches. --- lib/database.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/database.cc') diff --git a/lib/database.cc b/lib/database.cc index f8c4a7d1..df996a9a 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -956,7 +956,7 @@ notmuch_database_upgrade (notmuch_database_t *notmuch, document.get_value (NOTMUCH_VALUE_TIMESTAMP)); directory = _notmuch_directory_create (notmuch, term.c_str() + 10, - &status); + NOTMUCH_FIND_CREATE, &status); notmuch_directory_set_mtime (directory, mtime); notmuch_directory_destroy (directory); } @@ -1210,7 +1210,7 @@ _notmuch_database_find_directory_id (notmuch_database_t *notmuch, return NOTMUCH_STATUS_SUCCESS; } - directory = _notmuch_directory_create (notmuch, path, &status); + directory = _notmuch_directory_create (notmuch, path, NOTMUCH_FIND_CREATE, &status); if (status) { *directory_id = -1; return status; @@ -1320,7 +1320,7 @@ notmuch_database_get_directory (notmuch_database_t *notmuch, return NOTMUCH_STATUS_READ_ONLY_DATABASE; try { - *directory = _notmuch_directory_create (notmuch, path, &status); + *directory = _notmuch_directory_create (notmuch, path, NOTMUCH_FIND_CREATE, &status); } catch (const Xapian::Error &error) { fprintf (stderr, "A Xapian exception occurred getting directory: %s.\n", error.get_msg().c_str()); -- cgit v1.2.3