]> git.notmuchmail.org Git - sup/commitdiff
Merge branch 'various-mbox-fixes' into next
authorWilliam Morgan <wmorgan-sup@masanjin.net>
Wed, 29 Apr 2009 17:53:19 +0000 (13:53 -0400)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Wed, 29 Apr 2009 17:53:19 +0000 (13:53 -0400)
Conflicts:

lib/sup/mbox.rb

lib/sup/mbox.rb
lib/sup/mbox/loader.rb
lib/sup/message.rb
lib/sup/poll.rb
test/dummy_source.rb

index 5dd89b707d4709678d346a9f4490e2a3a672f101..53b4e8ce65cdd67f836154feeb59bde8202679a2 100644 (file)
@@ -6,6 +6,6 @@ require "sup/rfc2047"
 module Redwood
 
 module MBox
-  BREAK_RE = /^From \S+/ ######### TODO REMOVE ME
+  BREAK_RE = /^From \S+@\S+ /
 end
 end
index c623239b290cf98b5d73d6db28223272ba994a0e..3d8ef6aa2d7ae5d17881c0cee57a0eca85b7131c 100644 (file)
@@ -68,13 +68,12 @@ class Loader < Source
     @mutex.synchronize do
       @f.seek offset
       begin
-        RMail::Mailbox::MBoxReader.new(@f).each_message do |input|
-          m = RMail::Parser.read(input)
-          if m.body && m.body.is_a?(String)
-            m.body.gsub!(/^>From /, "From ")
-          end
-          return m
-        end
+        ## don't use RMail::Mailbox::MBoxReader because it doesn't properly ignore
+        ## "From" at the start of a message body line.
+        string = ""
+        l = @f.gets
+        string << l until @f.eof? || (l = @f.gets) =~ BREAK_RE
+        RMail::Parser.read string
       rescue RMail::Parser::Error => e
         raise FatalSourceError, "error parsing mbox file: #{e.message}"
       end
index 263fde3fedd86a2919adc14116198832d066311c..e86075c5e6ffcd7675651c5b98d62f165e61b349 100644 (file)
@@ -190,7 +190,7 @@ class Message
   ## this is called when the message body needs to actually be loaded.
   def load_from_source!
     @chunks ||=
-      if @source.has_errors?
+      if @source.respond_to?(:has_errors?) && @source.has_errors?
         [Chunk::Text.new(error_message(@source.error.message).split("\n"))]
       else
         begin
@@ -364,6 +364,7 @@ private
     [notice, sig, children].flatten.compact
   end
 
+  ## takes a RMail::Message, breaks it into Chunk:: classes.
   def message_to_chunks m, encrypted=false, sibling_types=[]
     if m.multipart?
       chunks =
index 3cb0b5b446d95218f7584fb3a0e9362b4c1f14d4..2d2ae0cc8c383a6ea08e0bbfff900845881e85f1 100644 (file)
@@ -86,7 +86,7 @@ EOS
       Index.usual_sources.each do |source|
 #        yield "source #{source} is done? #{source.done?} (cur_offset #{source.cur_offset} >= #{source.end_offset})"
         begin
-          yield "Loading from #{source}... " unless source.done? || source.has_errors?
+          yield "Loading from #{source}... " unless source.done? || (source.respond_to?(:has_errors?) && source.has_errors?)
         rescue SourceError => e
           Redwood::log "problem getting messages from #{source}: #{e.message}"
           Redwood::report_broken_sources :force_to_top => true
index b84e64e8da0cf1a6b2b45a10be192cd44d3233c6..83790c5dcaeb26ff716bb7b87537373eb8a79def 100644 (file)
@@ -53,13 +53,6 @@ class DummySource < Source
       yield f.gets
     end
   end
-
-  # FIXME: this one was not mentioned in the source documentation, but
-  # it's still required
-  def has_errors?
-
-  end
-
 end
 
 end