X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fdatabase.cc;h=b8486f7d5271771648ef0ff1ec71c8887a43b391;hp=f39d4485076cf9e855f6d7fe2401d4b1cf1894b4;hb=a352d9ceaa7e08b7c9de294419ec4c323b81ca15;hpb=87ee9a53e36f395e73e16da12cb268a708147259 diff --git a/lib/database.cc b/lib/database.cc index f39d4485..b8486f7d 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -1450,9 +1450,10 @@ notmuch_database_upgrade (notmuch_database_t *notmuch, query = notmuch_query_create (notmuch, ""); - /* XXX: this should use the _st version, but needs an error - path */ - for (messages = notmuch_query_search_messages (query); + status = notmuch_query_search_messages_st (query, &messages); + if (status) + goto DONE; + for (; notmuch_messages_valid (messages); notmuch_messages_move_to_next (messages)) { @@ -1634,6 +1635,9 @@ notmuch_database_begin_atomic (notmuch_database_t *notmuch) notmuch->atomic_nesting > 0) goto DONE; + if (notmuch_database_needs_upgrade(notmuch)) + return NOTMUCH_STATUS_UPGRADE_REQUIRED; + try { (static_cast (notmuch->xapian_db))->begin_transaction (false); } catch (const Xapian::Error &error) { @@ -1777,7 +1781,7 @@ _notmuch_database_split_path (void *ctx, /* Finally, skip multiple slashes. */ while (slash != path) { - if (*slash != '/') + if (*(slash - 1) != '/') break; --slash; @@ -1790,7 +1794,7 @@ _notmuch_database_split_path (void *ctx, *basename = path; } else { if (directory) - *directory = talloc_strndup (ctx, path, slash - path + 1); + *directory = talloc_strndup (ctx, path, slash - path); } return NOTMUCH_STATUS_SUCCESS;