---
bindings/python-cffi/notmuch2/_build.py | 3 +++
bindings/python-cffi/notmuch2/_database.py | 15 +++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/bindings/python-cffi/notmuch2/_build.py
b/bindings/python-cffi/notmuch2/_build.py
index 65d7dcb6..0429691a 100644
--- a/bindings/python-cffi/notmuch2/_build.py
+++ b/bindings/python-cffi/notmuch2/_build.py
@@ -118,6 +118,9 @@ ffibuilder.cdef(
notmuch_database_t **database,
char **error_message);
notmuch_status_t
+ notmuch_database_reopen (notmuch_database_t *database,
+ notmuch_database_mode_t new_mode);
+ notmuch_status_t
notmuch_database_close (notmuch_database_t *database);
notmuch_status_t
notmuch_database_destroy (notmuch_database_t *database);
diff --git a/bindings/python-cffi/notmuch2/_database.py
b/bindings/python-cffi/notmuch2/_database.py
index c13d9fcf..3e436be0 100644
--- a/bindings/python-cffi/notmuch2/_database.py
+++ b/bindings/python-cffi/notmuch2/_database.py
@@ -285,6 +285,21 @@ class Database(base.NotmuchObject):
raise errors.NotmuchError(ret)
self.closed = True
+ def reopen(self, mode=None):
+ """Reopen an opened notmuch database.
+
+ This is primarily useful to recover from OperationInvalidatedError.
+ """
+ if isinstance(mode, str):
+ mode = self.STR_MODE_MAP[mode]
+ else:
+ mode = mode or self.mode
+ self.mode = mode
+
+ ret = capi.lib.notmuch_database_reopen(self._db_p, mode.value)
+ if ret != capi.lib.NOTMUCH_STATUS_SUCCESS:
+ raise errors.NotmuchError(ret)
+
def __enter__(self):
return self
--
2.39.5
_______________________________________________
notmuch mailing list -- [email protected]
To unsubscribe send an email to [email protected]