unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 238584e2b1bf710785292f52d81cba529855c656 810 bytes (raw)
name: test/make-db-version.cc 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 
/* Create an empty notmuch database with a specific version and
 * features. */

#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>

#include <xapian.h>

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);
    }
}

debug log:

solving 238584e2 ...
found 238584e2 in https://yhetil.org/notmuch.git/

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).