aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/notmuch.h
diff options
context:
space:
mode:
authorGravatar Austin Clements <amdragon@mit.edu>2014-08-25 13:26:08 -0400
committerGravatar David Bremner <david@tethera.net>2014-08-30 11:39:41 -0700
commitec573cd54fb3ea98f37a3c3612b00fb16e34578b (patch)
tree791dff9c9fdc11afacd5a316a04409fdb2f16de7 /lib/notmuch.h
parent5dbfed4a73d8c310afa51108af1ca6484506145a (diff)
lib: Return an error from operations that require an upgrade
Previously, there was no protection against a caller invoking an operation on an old database version that would effectively corrupt the database by treating it like a newer version. According to notmuch.h, any caller that opens the database in read/write mode is supposed to check if the database needs upgrading and perform an upgrade if it does. This would protect against this, but nobody (even the CLI) actually does this. However, with features, it's easy to protect against incompatible operations on a fine-grained basis. This lightweight change allows callers to safely operate on old database versions, while preventing specific operations that would corrupt the database with an informative error message.
Diffstat (limited to 'lib/notmuch.h')
-rw-r--r--lib/notmuch.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 3c5ec988..cbf2ba5c 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -160,6 +160,10 @@ typedef enum _notmuch_status {
*/
NOTMUCH_STATUS_UNSUPPORTED_OPERATION,
/**
+ * The operation requires a database upgrade.
+ */
+ NOTMUCH_STATUS_UPGRADE_REQUIRED,
+ /**
* Not an actual status value. Just a way to find out how many
* valid status values there are.
*/
@@ -438,6 +442,9 @@ notmuch_database_end_atomic (notmuch_database_t *notmuch);
*
* NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred;
* directory not retrieved.
+ *
+ * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the
+ * database to use this function.
*/
notmuch_status_t
notmuch_database_get_directory (notmuch_database_t *database,
@@ -490,6 +497,9 @@ notmuch_database_get_directory (notmuch_database_t *database,
*
* NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
* mode so no message can be added.
+ *
+ * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the
+ * database to use this function.
*/
notmuch_status_t
notmuch_database_add_message (notmuch_database_t *database,
@@ -520,6 +530,9 @@ notmuch_database_add_message (notmuch_database_t *database,
*
* NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
* mode so no message can be removed.
+ *
+ * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the
+ * database to use this function.
*/
notmuch_status_t
notmuch_database_remove_message (notmuch_database_t *database,
@@ -575,6 +588,9 @@ notmuch_database_find_message (notmuch_database_t *database,
* NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory, creating the message object
*
* NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred
+ *
+ * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the
+ * database to use this function.
*/
notmuch_status_t
notmuch_database_find_message_by_filename (notmuch_database_t *notmuch,