]> git.notmuchmail.org Git - notmuch/blobdiff - lib/database.cc
lib: API to retrieve database revision and UUID
[notmuch] / lib / database.cc
index 52e2e8f16187bfc4dcd17b81c02473b95ebc2660..fc78769318cce7d15f0e950a3b638d2f68a6a920 100644 (file)
@@ -992,6 +992,8 @@ notmuch_database_open_verbose (const char *path,
            notmuch->revision = 0;
        else
            notmuch->revision = Xapian::sortable_unserialise (last_mod);
            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;
 
        notmuch->query_parser = new Xapian::QueryParser;
        notmuch->term_gen = new Xapian::TermGenerator;
@@ -1666,6 +1668,15 @@ DONE:
     return NOTMUCH_STATUS_SUCCESS;
 }
 
     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.
 /* 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.