X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fdatabase.cc;h=94022d7ce3ae9c060ecf18baaca1aa95afa11781;hp=98f101e6e617a04e9b6c26213f7e35a03dd5c0c3;hb=6c0adab23eadb81bb1254f4b82175902df11bb3f;hpb=69dc421ab3355930f23ec6aa47e7e936cbfafb97 diff --git a/lib/database.cc b/lib/database.cc index 98f101e6..94022d7c 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -28,6 +28,8 @@ #include /* g_free, GPtrArray, GHashTable */ #include /* g_type_init */ +#include /* g_mime_init */ + using namespace std; #define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0])) @@ -81,13 +83,17 @@ typedef struct { * STRING is the name of a file within that * directory for this mail message. * - * A mail document also has two values: + * A mail document also has four values: * * TIMESTAMP: The time_t value corresponding to the message's * Date header. * * MESSAGE_ID: The unique ID of the mail mess (see "id" above) * + * FROM: The value of the "From" header + * + * SUBJECT: The value of the "Subject" header + * * In addition, terms from the content of the message are added with * "from", "to", "attachment", and "subject" prefixes for use by the * user in searching. Similarly, terms from the path of the mail @@ -581,6 +587,7 @@ notmuch_database_open (const char *path, struct stat st; int err; unsigned int i, version; + static int initialized = 0; if (asprintf (¬much_path, "%s/%s", path, ".notmuch") == -1) { notmuch_path = NULL; @@ -604,7 +611,13 @@ notmuch_database_open (const char *path, /* Initialize the GLib type system and threads */ g_type_init (); - notmuch = talloc (NULL, notmuch_database_t); + /* Initialize gmime */ + if (! initialized) { + g_mime_init (0); + initialized = 1; + } + + notmuch = talloc_zero (NULL, notmuch_database_t); notmuch->exception_reported = FALSE; notmuch->path = talloc_strdup (notmuch, path); @@ -690,6 +703,7 @@ notmuch_database_open (const char *path, } catch (const Xapian::Error &error) { fprintf (stderr, "A Xapian exception occurred opening database: %s\n", error.get_msg().c_str()); + notmuch_database_close (notmuch); notmuch = NULL; } @@ -1447,7 +1461,7 @@ _notmuch_database_link_message_to_parents (notmuch_database_t *notmuch, keys = g_hash_table_get_keys (parents); for (l = keys; l; l = l->next) { char *parent_message_id; - const char *parent_thread_id; + const char *parent_thread_id = NULL; parent_message_id = (char *) l->data;