diff --git a/notmuch/mutt_notmuch.c b/notmuch/mutt_notmuch.c index cd28eb89ced..7786ba861f5 100644 --- a/notmuch/mutt_notmuch.c +++ b/notmuch/mutt_notmuch.c @@ -597,8 +597,7 @@ static notmuch_query_t *get_query(struct Mailbox *m, bool writable) mutt_debug(2, "nm: query successfully initialized (%s)\n", str); return q; err: - if (!nm_db_is_longrun(m)) - nm_db_release(m); + nm_db_release(m); return NULL; } @@ -1637,8 +1636,8 @@ int nm_read_entire_thread(struct Context *ctx, struct Email *e) done: if (q) notmuch_query_destroy(q); - if (!nm_db_is_longrun(m)) - nm_db_release(m); + + nm_db_release(m); if (m->msg_count == mdata->oldmsgcount) mutt_message(_("No more messages in the thread")); @@ -1853,8 +1852,7 @@ int nm_update_filename(struct Mailbox *m, const char *old, const char *new, stru int rc = rename_filename(m, old, new, e); - if (!nm_db_is_longrun(m)) - nm_db_release(m); + nm_db_release(m); m->mtime.tv_sec = time(NULL); m->mtime.tv_nsec = 0; return rc; @@ -2028,8 +2026,8 @@ int nm_record_message(struct Mailbox *m, char *path, struct Email *e) notmuch_message_destroy(msg); if (trans == 1) nm_db_trans_end(m); - if (!nm_db_is_longrun(m)) - nm_db_release(m); + + nm_db_release(m); return rc; } @@ -2078,8 +2076,7 @@ int nm_get_all_tags(struct Mailbox *m, char **tag_list, int *tag_count) if (tags) notmuch_tags_destroy(tags); - if (!nm_db_is_longrun(m)) - nm_db_release(m); + nm_db_release(m); mutt_debug(1, "nm: get all tags done [rc=%d tag_count=%u]\n", rc, *tag_count); return rc; @@ -2165,8 +2162,7 @@ static int nm_mbox_open(struct Mailbox *m, struct Context *ctx) notmuch_query_destroy(q); } - if (!nm_db_is_longrun(m)) - nm_db_release(m); + nm_db_release(m); m->mtime.tv_sec = time(NULL); m->mtime.tv_nsec = 0; @@ -2295,8 +2291,7 @@ static int nm_mbox_check(struct Context *ctx, int *index_hint) if (q) notmuch_query_destroy(q); - if (!nm_db_is_longrun(m)) - nm_db_release(m); + nm_db_release(m); m->mtime.tv_sec = time(NULL); m->mtime.tv_nsec = 0; @@ -2389,8 +2384,8 @@ static int nm_mbox_sync(struct Context *ctx, int *index_hint) mutt_str_strfcpy(m->path, uri, sizeof(m->path)); m->magic = MUTT_NOTMUCH; - if (!nm_db_is_longrun(m)) - nm_db_release(m); + nm_db_release(m); + if (changed) { m->mtime.tv_sec = time(NULL); @@ -2500,8 +2495,7 @@ static int nm_tags_commit(struct Mailbox *m, struct Email *e, char *buf) rc = 0; e->changed = true; done: - if (!nm_db_is_longrun(m)) - nm_db_release(m); + nm_db_release(m); if (e->changed) { m->mtime.tv_sec = time(NULL); diff --git a/notmuch/nm_db.c b/notmuch/nm_db.c index f5748ec6706..1fd7f3490a8 100644 --- a/notmuch/nm_db.c +++ b/notmuch/nm_db.c @@ -162,7 +162,7 @@ notmuch_database_t *nm_db_get(struct Mailbox *m, bool writable) int nm_db_release(struct Mailbox *m) { struct NmAccountData *adata = nm_adata_get(m); - if (!adata || !adata->db) + if (!adata || !adata->db || nm_db_is_longrun(m)) return -1; mutt_debug(1, "nm: db close\n");