From: Austin Clements <amdragon@MIT.EDU>
To: notmuch@notmuchmail.org
Subject: [PATCH 3/9] lib: Perform the same transformation to _notmuch_database_filename_to_direntry
Date: Fri, 18 May 2012 00:13:36 -0400 [thread overview]
Message-ID: <1337314423-3702-4-git-send-email-amdragon@mit.edu> (raw)
In-Reply-To: <1337314423-3702-1-git-send-email-amdragon@mit.edu>
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.
---
lib/database.cc | 17 +++++++++++------
lib/message.cc | 9 ++++-----
lib/notmuch-private.h | 1 +
3 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/lib/database.cc b/lib/database.cc
index 716982d..b4c76b4 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -1248,13 +1248,16 @@ _notmuch_database_get_directory_path (void *ctx,
* 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_find_flags_t flags,
char **direntry)
{
const char *relative, *directory, *basename;
@@ -1268,10 +1271,12 @@ _notmuch_database_filename_to_direntry (void *ctx,
if (status)
return status;
- status = _notmuch_database_find_directory_id (notmuch, directory, NOTMUCH_FIND_CREATE,
+ status = _notmuch_database_find_directory_id (notmuch, directory, flags,
&directory_id);
- if (status)
+ if (status || directory_id == (unsigned int)-1) {
+ *direntry = NULL;
return status;
+ }
*direntry = talloc_asprintf (ctx, "%u:%s", directory_id, basename);
@@ -1892,8 +1897,8 @@ notmuch_database_find_message_by_filename (notmuch_database_t *notmuch,
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)
goto DONE;
diff --git a/lib/message.cc b/lib/message.cc
index 0075425..8d552f1 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -495,9 +495,8 @@ _notmuch_message_add_filename (notmuch_message_t *message,
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;
@@ -541,8 +540,8 @@ _notmuch_message_remove_filename (notmuch_message_t *message,
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;
diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index a36549d..34f7ac7 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -207,6 +207,7 @@ notmuch_status_t
_notmuch_database_filename_to_direntry (void *ctx,
notmuch_database_t *notmuch,
const char *filename,
+ notmuch_find_flags_t flags,
char **direntry);
/* directory.cc */
--
1.7.10
next prev parent reply other threads:[~2012-05-18 4:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-18 4:13 [PATCH 0/9] Fix directory lookup on read-only databases Austin Clements
2012-05-18 4:13 ` [PATCH 1/9] lib: Make directory document creation optional for _notmuch_directory_create Austin Clements
2012-05-24 1:53 ` David Bremner
2012-05-18 4:13 ` [PATCH 2/9] lib: Perform the same transformation to _notmuch_database_find_directory_id Austin Clements
2012-05-18 4:13 ` Austin Clements [this message]
2012-05-18 4:13 ` [PATCH 4/9] lib: Make notmuch_database_get_directory return NULL if the directory is not found Austin Clements
2012-05-18 4:13 ` [PATCH 5/9] new: Remove workaround for detecting newly created directory objects Austin Clements
2012-05-18 4:13 ` [PATCH 6/9] python: Update Database.get_directory documentation Austin Clements
2012-05-18 4:13 ` [PATCH 7/9] lib: Make notmuch_database_find_message_by_filename not crash on read-only databases Austin Clements
2012-05-18 4:13 ` [PATCH 8/9] python: Remove find_message_by_filename workaround Austin Clements
2012-05-18 4:13 ` [PATCH 9/9] lib: Don't needlessly create directory docs in _notmuch_message_remove_filename Austin Clements
2012-05-22 20:48 ` [PATCH 0/9] Fix directory lookup on read-only databases Tomi Ollila
2012-05-23 10:28 ` Justus Winter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1337314423-3702-4-git-send-email-amdragon@mit.edu \
--to=amdragon@mit.edu \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).