Index an attachment's filename extension as well.
authorCarl Worth <cworth@cworth.org>
Wed, 14 Oct 2009 23:35:03 +0000 (16:35 -0700)
committerCarl Worth <cworth@cworth.org>
Wed, 14 Oct 2009 23:35:03 +0000 (16:35 -0700)
I hadn't realized that sup used a special term for this. But there
you go.

notmuch-index-message.cc

index 636757a165ac68e47a56af69817c25496afa1123..3270aac7cfcdc640d619b19d7ceef1f7170196cc 100644 (file)
@@ -443,9 +443,20 @@ gen_terms_part (Xapian::TermGenerator term_gen,
     if (disposition &&
        strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0)
     {
+       const char *filename = g_mime_part_get_filename (GMIME_PART (part));
+       const char *extension;
+
        add_term (term_gen.get_document (), "label", "attachment");
-       gen_terms (term_gen, "attachment",
-                 g_mime_part_get_filename (GMIME_PART (part)));
+       gen_terms (term_gen, "attachment", filename);
+
+       if (filename) {
+           extension = strchr (filename, '.');
+           if (extension) {
+               add_term (term_gen.get_document (), "attachment_extension",
+                         extension + 1);
+           }
+       }
+
        return;
     }