]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch-new.c
CLI/new: drop the write lock to run the pre-new hook.
[notmuch] / notmuch-new.c
index 223d68bb2530ed7eb1981e3782721d40f99d254b..8214fb23a81b55af1ae00248e25e06bd1e3d003e 100644 (file)
@@ -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);