[PATCH 02/22] lib: publish API for notmuch_database_reopen

2021-03-14 Thread David Bremner
Include the (currently unused) mode argument which will specify which
mode to re-open the database in. Functionality and docs to be
finalized in a followup commit.
---
 lib/database.cc   | 3 ++-
 lib/message.cc| 3 ++-
 lib/notmuch-private.h | 3 ---
 lib/notmuch.h | 7 +++
 4 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index f27616da..82ac5f20 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -518,7 +518,8 @@ notmuch_database_close (notmuch_database_t *notmuch)
 }
 
 notmuch_status_t
-_notmuch_database_reopen (notmuch_database_t *notmuch)
+notmuch_database_reopen (notmuch_database_t *notmuch,
+unused(notmuch_database_mode_t mode))
 {
 if (_notmuch_database_mode (notmuch) != NOTMUCH_DATABASE_MODE_READ_ONLY)
return NOTMUCH_STATUS_UNSUPPORTED_OPERATION;
diff --git a/lib/message.cc b/lib/message.cc
index dc4b47dc..73a7805f 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -459,7 +459,8 @@ _notmuch_message_ensure_metadata (notmuch_message_t 
*message, void *field)
/* all the way without an exception */
break;
} catch (const Xapian::DatabaseModifiedError &error) {
-   notmuch_status_t status = _notmuch_database_reopen 
(message->notmuch);
+   notmuch_status_t status = notmuch_database_reopen (message->notmuch,
+  
NOTMUCH_DATABASE_MODE_READ_ONLY);
if (status != NOTMUCH_STATUS_SUCCESS)
INTERNAL_ERROR ("unhandled error from notmuch_database_reopen: 
%s\n",
notmuch_status_to_string (status));
diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index 3c52cfc2..ef814378 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -204,9 +204,6 @@ _notmuch_message_id_compressed (void *ctx, const char 
*message_id);
 notmuch_status_t
 _notmuch_database_ensure_writable (notmuch_database_t *notmuch);
 
-notmuch_status_t
-_notmuch_database_reopen (notmuch_database_t *notmuch);
-
 void
 _notmuch_database_log (notmuch_database_t *notmuch,
   const char *format, ...);
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 58c568d5..db86ffc0 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -879,6 +879,13 @@ notmuch_database_find_message_by_filename 
(notmuch_database_t *notmuch,
 notmuch_tags_t *
 notmuch_database_get_all_tags (notmuch_database_t *db);
 
+/**
+ * Reopen an open notmuch database.
+ *
+ */
+notmuch_status_t
+notmuch_database_reopen (notmuch_database_t *db, notmuch_database_mode_t mode);
+
 /**
  * Create a new query for 'database'.
  *
-- 
2.30.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 02/22] lib: publish API for notmuch_database_reopen

2021-03-07 Thread David Bremner
Include the (currently unused) mode argument which will specify which
mode to re-open the database in. Functionality and docs to be
finalized in a followup commit.
---
 lib/database.cc   | 3 ++-
 lib/message.cc| 3 ++-
 lib/notmuch-private.h | 3 ---
 lib/notmuch.h | 7 +++
 4 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index b4e536b9..799c008f 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -517,7 +517,8 @@ notmuch_database_close (notmuch_database_t *notmuch)
 }
 
 notmuch_status_t
-_notmuch_database_reopen (notmuch_database_t *notmuch)
+notmuch_database_reopen (notmuch_database_t *notmuch,
+unused(notmuch_database_mode_t mode))
 {
 if (_notmuch_database_mode (notmuch) != NOTMUCH_DATABASE_MODE_READ_ONLY)
return NOTMUCH_STATUS_UNSUPPORTED_OPERATION;
diff --git a/lib/message.cc b/lib/message.cc
index fca99082..1bea90f0 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -455,7 +455,8 @@ _notmuch_message_ensure_metadata (notmuch_message_t 
*message, void *field)
/* all the way without an exception */
break;
} catch (const Xapian::DatabaseModifiedError &error) {
-   notmuch_status_t status = _notmuch_database_reopen 
(message->notmuch);
+   notmuch_status_t status = notmuch_database_reopen (message->notmuch,
+  
NOTMUCH_DATABASE_MODE_READ_ONLY);
if (status != NOTMUCH_STATUS_SUCCESS)
INTERNAL_ERROR ("unhandled error from notmuch_database_reopen: 
%s\n",
notmuch_status_to_string (status));
diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index e47badbc..1174c43c 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -204,9 +204,6 @@ _notmuch_message_id_compressed (void *ctx, const char 
*message_id);
 notmuch_status_t
 _notmuch_database_ensure_writable (notmuch_database_t *notmuch);
 
-notmuch_status_t
-_notmuch_database_reopen (notmuch_database_t *notmuch);
-
 void
 _notmuch_database_log (notmuch_database_t *notmuch,
   const char *format, ...);
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 70f4f517..05edac31 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -879,6 +879,13 @@ notmuch_database_find_message_by_filename 
(notmuch_database_t *notmuch,
 notmuch_tags_t *
 notmuch_database_get_all_tags (notmuch_database_t *db);
 
+/**
+ * Reopen an open notmuch database.
+ *
+ */
+notmuch_status_t
+notmuch_database_reopen (notmuch_database_t *db, notmuch_database_mode_t mode);
+
 /**
  * Create a new query for 'database'.
  *
-- 
2.30.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 02/22] lib: publish API for notmuch_database_reopen

2021-03-04 Thread David Bremner
Include the (currently unused) mode argument which will specify which
mode to re-open the database in. Functionality and docs to be
finalized in a followup commit.
---
 lib/database.cc   | 3 ++-
 lib/message.cc| 3 ++-
 lib/notmuch-private.h | 3 ---
 lib/notmuch.h | 7 +++
 4 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index f96ba7c0..89865599 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -516,7 +516,8 @@ notmuch_database_close (notmuch_database_t *notmuch)
 }
 
 notmuch_status_t
-_notmuch_database_reopen (notmuch_database_t *notmuch)
+notmuch_database_reopen (notmuch_database_t *notmuch,
+unused(notmuch_database_mode_t mode))
 {
 if (_notmuch_database_mode (notmuch) != NOTMUCH_DATABASE_MODE_READ_ONLY)
return NOTMUCH_STATUS_UNSUPPORTED_OPERATION;
diff --git a/lib/message.cc b/lib/message.cc
index fca99082..1bea90f0 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -455,7 +455,8 @@ _notmuch_message_ensure_metadata (notmuch_message_t 
*message, void *field)
/* all the way without an exception */
break;
} catch (const Xapian::DatabaseModifiedError &error) {
-   notmuch_status_t status = _notmuch_database_reopen 
(message->notmuch);
+   notmuch_status_t status = notmuch_database_reopen (message->notmuch,
+  
NOTMUCH_DATABASE_MODE_READ_ONLY);
if (status != NOTMUCH_STATUS_SUCCESS)
INTERNAL_ERROR ("unhandled error from notmuch_database_reopen: 
%s\n",
notmuch_status_to_string (status));
diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index 750a242c..2808bbb3 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -204,9 +204,6 @@ _notmuch_message_id_compressed (void *ctx, const char 
*message_id);
 notmuch_status_t
 _notmuch_database_ensure_writable (notmuch_database_t *notmuch);
 
-notmuch_status_t
-_notmuch_database_reopen (notmuch_database_t *notmuch);
-
 void
 _notmuch_database_log (notmuch_database_t *notmuch,
   const char *format, ...);
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 5a5d99c0..0c13f607 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -879,6 +879,13 @@ notmuch_database_find_message_by_filename 
(notmuch_database_t *notmuch,
 notmuch_tags_t *
 notmuch_database_get_all_tags (notmuch_database_t *db);
 
+/**
+ * Reopen an open notmuch database.
+ *
+ */
+notmuch_status_t
+notmuch_database_reopen (notmuch_database_t *db, notmuch_database_mode_t mode);
+
 /**
  * Create a new query for 'database'.
  *
-- 
2.30.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org