X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=test%2Fmake-db-version.cc;fp=test%2Fmake-db-version.cc;h=fa80cac9d321993154e29bd5ea52ae8d43aa5809;hb=d06adc52e03cefe6263aeffa01353ad59d13fb54;hp=0000000000000000000000000000000000000000;hpb=8363c9053152d349022b821a4a343f0ee2ade318;p=notmuch diff --git a/test/make-db-version.cc b/test/make-db-version.cc new file mode 100644 index 00000000..fa80cac9 --- /dev/null +++ b/test/make-db-version.cc @@ -0,0 +1,35 @@ +/* Create an empty notmuch database with a specific version and + * features. */ + +#include +#include +#include +#include + +#include + +int main(int argc, char **argv) +{ + if (argc != 4) { + fprintf (stderr, "Usage: %s mailpath version features\n", argv[0]); + exit (2); + } + + std::string nmpath (argv[1]); + nmpath += "/.notmuch"; + if (mkdir (nmpath.c_str (), 0777) < 0) { + perror (("failed to create " + nmpath).c_str ()); + exit (1); + } + + try { + Xapian::WritableDatabase db ( + nmpath + "/xapian", Xapian::DB_CREATE_OR_OPEN); + db.set_metadata ("version", argv[2]); + db.set_metadata ("features", argv[3]); + db.commit (); + } catch (const Xapian::Error &e) { + fprintf (stderr, "%s\n", e.get_description ().c_str ()); + exit (1); + } +}