lib: Make notmuch_database_find_message_by_filename not crash on read-only databases
authorAustin Clements <amdragon@MIT.EDU>
Fri, 18 May 2012 04:13:40 +0000 (00:13 -0400)
committerDavid Bremner <bremner@debian.org>
Thu, 24 May 2012 01:31:47 +0000 (22:31 -0300)
Previously, _notmuch_database_filename_to_direntry would abort with an
internal error when called on a read-only database.  Now that creating
the directory document is optional,
notmuch_database_find_message_by_filename can disable directory
document creation (as it should) and, as a result, not abort on
read-only databases.

lib/database.cc

index e27a0e1664cfac7d2731402f7e3c675c19f57eda..761dc1a24c3a26247dcfa7734ceb7141f02df36a 100644 (file)
@@ -1895,8 +1895,8 @@ notmuch_database_find_message_by_filename (notmuch_database_t *notmuch,
 
     try {
        status = _notmuch_database_filename_to_direntry (
 
     try {
        status = _notmuch_database_filename_to_direntry (
-           local, notmuch, filename, NOTMUCH_FIND_CREATE, &direntry);
-       if (status)
+           local, notmuch, filename, NOTMUCH_FIND_LOOKUP, &direntry);
+       if (status || !direntry)
            goto DONE;
 
        term = talloc_asprintf (local, "%s%s", prefix, direntry);
            goto DONE;
 
        term = talloc_asprintf (local, "%s%s", prefix, direntry);