lib: add NOTMUCH_STATUS_DATABASE_EXISTS

It is desirable to distinguish between attempting to create a database
that already exists, and more fatal errors like permission problems.
This commit is contained in:
David Bremner 2021-01-03 08:50:12 -04:00
parent c447fe92c7
commit 55f5e87096
3 changed files with 8 additions and 0 deletions

View file

@ -51,6 +51,7 @@ ffibuilder.cdef(
NOTMUCH_STATUS_FAILED_CRYPTO_CONTEXT_CREATION, NOTMUCH_STATUS_FAILED_CRYPTO_CONTEXT_CREATION,
NOTMUCH_STATUS_UNKNOWN_CRYPTO_PROTOCOL, NOTMUCH_STATUS_UNKNOWN_CRYPTO_PROTOCOL,
NOTMUCH_STATUS_NO_CONFIG, NOTMUCH_STATUS_NO_CONFIG,
NOTMUCH_STATUS_DATABASE_EXISTS,
NOTMUCH_STATUS_LAST_STATUS NOTMUCH_STATUS_LAST_STATUS
} notmuch_status_t; } notmuch_status_t;
typedef enum { typedef enum {

View file

@ -52,6 +52,8 @@ class NotmuchError(Exception):
IllegalArgumentError, IllegalArgumentError,
capi.lib.NOTMUCH_STATUS_NO_CONFIG: capi.lib.NOTMUCH_STATUS_NO_CONFIG:
NoConfigError, NoConfigError,
capi.lib.NOTMUCH_STATUS_DATABASE_EXISTS:
DatabaseExistsError,
} }
return types[status] return types[status]
@ -97,6 +99,7 @@ class UpgradeRequiredError(NotmuchError): pass
class PathError(NotmuchError): pass class PathError(NotmuchError): pass
class IllegalArgumentError(NotmuchError): pass class IllegalArgumentError(NotmuchError): pass
class NoConfigError(NotmuchError): pass class NoConfigError(NotmuchError): pass
class DatabaseExistsError(NotmuchError): pass
class ObjectDestroyedError(NotmuchError): class ObjectDestroyedError(NotmuchError):
"""The object has already been destroyed and it's memory freed. """The object has already been destroyed and it's memory freed.

View file

@ -212,6 +212,10 @@ typedef enum _notmuch_status {
* Unable to load a config file * Unable to load a config file
*/ */
NOTMUCH_STATUS_NO_CONFIG, NOTMUCH_STATUS_NO_CONFIG,
/**
* Database exists, so not (re)-created
*/
NOTMUCH_STATUS_DATABASE_EXISTS,
/** /**
* Not an actual status value. Just a way to find out how many * Not an actual status value. Just a way to find out how many
* valid status values there are. * valid status values there are.