diff options
author | David Bremner <david@tethera.net> | 2021-03-18 22:58:02 -0300 |
---|---|---|
committer | David Bremner <david@tethera.net> | 2021-03-18 22:58:02 -0300 |
commit | a9f74aeeb9ade477d5b80c1c2700945d6c50adb1 (patch) | |
tree | 633ba076d59bd991c3f66311cbaf2dfbb291d105 /notmuch-new.c | |
parent | 7d286f0272feb08aea8c1bee0b0ec6cd9766aee7 (diff) |
CLI/new: drop the write lock to run the pre-new hook.
This fixes a bug reported in [1]. In principle it could be possible
avoid one of these reopens, but it complicates the logic in main with
respect to creating new databases.
[1]: id:9C1993DF-84BD-4199-A9C8-BADA98498812@bubblegen.co.uk
Diffstat (limited to 'notmuch-new.c')
-rw-r--r-- | notmuch-new.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/notmuch-new.c b/notmuch-new.c index 223d68bb..8214fb23 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -1170,9 +1170,19 @@ notmuch_new_command (unused(notmuch_config_t *config), notmuch_database_t *notmu } if (hooks) { + /* Drop write lock to run hook */ + status = notmuch_database_reopen (notmuch, NOTMUCH_DATABASE_MODE_READ_ONLY); + if (print_status_database ("notmuch new", notmuch, status)) + return EXIT_FAILURE; + ret = notmuch_run_hook (notmuch, "pre-new"); if (ret) return EXIT_FAILURE; + + /* acquire write lock again */ + status = notmuch_database_reopen (notmuch, NOTMUCH_DATABASE_MODE_READ_WRITE); + if (print_status_database ("notmuch new", notmuch, status)) + return EXIT_FAILURE; } notmuch_exit_if_unmatched_db_uuid (notmuch); |