]> git.cworth.org Git - sup/blobdiff - lib/sup/mbox/loader.rb
Merge branch 'message-id-normalization' into next
[sup] / lib / sup / mbox / loader.rb
index 605a2c63fee18871640778ce3690bb1140b3d3ac..58f4fc7d8fefbf2379edf315e6bc97ad8cc187ea 100644 (file)
@@ -6,6 +6,7 @@ module MBox
 
 class Loader < Source
   yaml_properties :uri, :cur_offset, :usual, :archived, :id, :labels
+  attr_accessor :labels
 
   ## uri_or_fp is horrific. need to refactor.
   def initialize uri_or_fp, start_offset=nil, usual=true, archived=false, id=nil, labels=[]
@@ -37,7 +38,7 @@ class Loader < Source
     if File.dirname(path) =~ /\b(var|usr|spool)\b/
       []
     else
-      [File.basename(path).intern]
+      [File.basename(path).downcase.intern]
     end
   end
 
@@ -69,7 +70,7 @@ class Loader < Source
       begin
         RMail::Mailbox::MBoxReader.new(@f).each_message do |input|
           m = RMail::Parser.read(input)
-          if m.body
+          if m.body && m.body.is_a?(String)
             m.body.gsub!(/^>From /, "From ")
           end
           return m
@@ -147,7 +148,7 @@ class Loader < Source
     end
 
     self.cur_offset = next_offset
-    [returned_offset, (@labels + [:unread]).uniq]
+    [returned_offset, (self.labels + [:unread]).uniq]
   end
 end