lib: Return an error from operations that require an upgrade
authorAustin Clements <amdragon@mit.edu>
Mon, 25 Aug 2014 17:26:08 +0000 (13:26 -0400)
committerDavid Bremner <david@tethera.net>
Sat, 30 Aug 2014 18:39:41 +0000 (11:39 -0700)
commitec573cd54fb3ea98f37a3c3612b00fb16e34578b
tree791dff9c9fdc11afacd5a316a04409fdb2f16de7
parent5dbfed4a73d8c310afa51108af1ca6484506145a
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.
lib/database.cc
lib/directory.cc
lib/message.cc
lib/notmuch.h