X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=notmuch-index-message.cc;h=5c73825ba2f48e3d7964994d497e104c1a6464a0;hb=914df660c423c078df20390a4b647edbe8fb712a;hp=efc7eb14cda4f2f6c386365443909857110149a2;hpb=48d2e2dc440d49d7305324c25460e98d5fa40bda;p=notmuch diff --git a/notmuch-index-message.cc b/notmuch-index-message.cc index efc7eb14..5c73825b 100644 --- a/notmuch-index-message.cc +++ b/notmuch-index-message.cc @@ -54,6 +54,7 @@ #include #include #include +#include #include @@ -252,6 +253,9 @@ skip_re_in_subject (const char *subject) { const char *s = subject; + if (subject == NULL) + return NULL; + while (*s) { while (*s && isspace (*s)) s++; @@ -503,7 +507,8 @@ gen_terms_part (Xapian::TermGenerator term_gen, stream = g_mime_stream_mem_new_with_byte_array (byte_array); g_mime_stream_mem_set_owner (GMIME_STREAM_MEM (stream), FALSE); wrapper = g_mime_part_get_content_object (GMIME_PART (part)); - g_mime_data_wrapper_write_to_stream (wrapper, stream); + if (wrapper) + g_mime_data_wrapper_write_to_stream (wrapper, stream); g_object_unref (stream); @@ -676,6 +681,8 @@ main (int argc, char **argv) GIOChannel *channel; GIOStatus gio_status; GError *error = NULL; + int count; + struct timeval tv_start, tv_now; if (argc < 2) { usage (argv[0]); @@ -697,6 +704,10 @@ main (int argc, char **argv) channel = g_io_channel_unix_new (fileno (stdin)); + count = 0; + + gettimeofday (&tv_start, NULL); + while (1) { gio_status = g_io_channel_read_line (channel, &filename, NULL, NULL, &error); @@ -712,6 +723,14 @@ main (int argc, char **argv) index_file (db, term_gen, filename); g_free (filename); + + count++; + if (count % 250 == 0) { + gettimeofday (&tv_now, NULL); + printf ("Indexed %d messages (%g messages/second)\n", + count, count / ((tv_now.tv_sec - tv_start.tv_sec) + + (tv_now.tv_usec - tv_start.tv_usec) / 1e6)); + } } } catch (const Xapian::Error &error) {