aboutsummaryrefslogtreecommitdiff
path: root/lib/database.cc
diff options
context:
space:
mode:
authorAustin Clements <aclements@csail.mit.edu>2014-10-13 02:20:02 -0400
committerDavid Bremner <david@tethera.net>2015-08-13 23:52:51 +0200
commit98ee460eaa98f1428aecf03dd39fcf314e6f62c0 (patch)
tree60fc701a61c88ea92bd009f0f662c8107360f56b /lib/database.cc
parent7f57b747b95eece465d10fd0acba20cc3dd868f1 (diff)
lib: API to retrieve database revision and UUID
This exposes the committed database revision to library users along with a UUID that can be used to detect when revision numbers are no longer comparable (e.g., because the database has been replaced).
Diffstat (limited to 'lib/database.cc')
-rw-r--r--lib/database.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/database.cc b/lib/database.cc
index 52e2e8f1..fc787693 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -992,6 +992,8 @@ notmuch_database_open_verbose (const char *path,
notmuch->revision = 0;
else
notmuch->revision = Xapian::sortable_unserialise (last_mod);
+ notmuch->uuid = talloc_strdup (
+ notmuch, notmuch->xapian_db->get_uuid ().c_str ());
notmuch->query_parser = new Xapian::QueryParser;
notmuch->term_gen = new Xapian::TermGenerator;
@@ -1666,6 +1668,15 @@ DONE:
return NOTMUCH_STATUS_SUCCESS;
}
+unsigned long
+notmuch_database_get_revision (notmuch_database_t *notmuch,
+ const char **uuid)
+{
+ if (uuid)
+ *uuid = notmuch->uuid;
+ return notmuch->revision;
+}
+
/* We allow the user to use arbitrarily long paths for directories. But
* we have a term-length limit. So if we exceed that, we'll use the
* SHA-1 of the path for the database term.