]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch-index-message.cc
Reduce the verbosity of the progress indicator.
[notmuch] / notmuch-index-message.cc
index 0b1072d759c481af6a8fd3812c5bf193c99dce91..f1f9e3ada90373a938b35d3fafde457012942006 100644 (file)
@@ -54,6 +54,7 @@
 #include <string.h>
 #include <errno.h>
 #include <time.h>
 #include <string.h>
 #include <errno.h>
 #include <time.h>
+#include <sys/time.h>
 
 #include <iostream>
 
 
 #include <iostream>
 
@@ -252,6 +253,9 @@ skip_re_in_subject (const char *subject)
 {
     const char *s = subject;
 
 {
     const char *s = subject;
 
+    if (subject == NULL)
+       return NULL;
+
     while (*s) {
        while (*s && isspace (*s))
            s++;
     while (*s) {
        while (*s && isspace (*s))
            s++;
@@ -471,7 +475,17 @@ gen_terms_part (Xapian::TermGenerator term_gen,
        return;
     }
 
        return;
     }
 
-    if (! GMIME_IS_PART (part)) {
+    if (GMIME_IS_MESSAGE_PART (part)) {
+       GMimeMessage *message;
+
+       message = g_mime_message_part_get_message (GMIME_MESSAGE_PART (part));
+
+       gen_terms_part (term_gen, g_mime_message_get_mime_part (message));
+
+       return;
+    }
+
+    if (! (GMIME_IS_PART (part))) {
        fprintf (stderr, "Warning: Not indexing unknown mime part: %s.\n",
                 g_type_name (G_OBJECT_TYPE (part)));
        return;
        fprintf (stderr, "Warning: Not indexing unknown mime part: %s.\n",
                 g_type_name (G_OBJECT_TYPE (part)));
        return;
@@ -677,6 +691,8 @@ main (int argc, char **argv)
     GIOChannel *channel;
     GIOStatus gio_status;
     GError *error = NULL;
     GIOChannel *channel;
     GIOStatus gio_status;
     GError *error = NULL;
+    int count;
+    struct timeval tv_start, tv_now;
 
     if (argc < 2) {
        usage (argv[0]);
 
     if (argc < 2) {
        usage (argv[0]);
@@ -698,6 +714,10 @@ main (int argc, char **argv)
 
        channel = g_io_channel_unix_new (fileno (stdin));
 
 
        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);
        while (1) {
            gio_status = g_io_channel_read_line (channel, &filename,
                                                 NULL, NULL, &error);
@@ -713,6 +733,14 @@ main (int argc, char **argv)
            index_file (db, term_gen, filename);
 
            g_free (filename);
            index_file (db, term_gen, filename);
 
            g_free (filename);
+
+           count++;
+           if (count % 1000 == 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) {
        }
 
     } catch (const Xapian::Error &error) {