[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sup-devel] [PATCH 01/10] open mail source files as binary



---
 lib/sup/maildir.rb     |    4 ++--
 lib/sup/mbox/loader.rb |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/sup/maildir.rb b/lib/sup/maildir.rb
index c2bd27a..0852576 100644
--- a/lib/sup/maildir.rb
+++ b/lib/sup/maildir.rb
@@ -59,7 +59,7 @@ class Maildir < Source
         File.stat(tmp_path)
       rescue Errno::ENOENT #this is what we want.
         begin
-          File.open(tmp_path, 'w') do |f|
+          File.open(tmp_path, 'wb:BINARY') do |f|
             yield f #provide a writable interface for the caller
             f.fsync
           end
@@ -207,7 +207,7 @@ private
   def with_file_for id
     fn = @ids_to_fns[id] or raise OutOfSyncSourceError, "No such id: #{id.inspect}."
     begin
-      File.open(fn) { |f| yield f }
+      File.open(fn, 'rb:BINARY') { |f| yield f }
     rescue SystemCallError, IOError => e
       raise FatalSourceError, "Problem reading file for id #{id.inspect}: #{fn.inspect}: #{e.message}."
     end
diff --git a/lib/sup/mbox/loader.rb b/lib/sup/mbox/loader.rb
index 520e2ec..ec28d3b 100644
--- a/lib/sup/mbox/loader.rb
+++ b/lib/sup/mbox/loader.rb
@@ -22,7 +22,7 @@ class Loader < Source
       raise ArgumentError, "not an mbox uri" unless uri.scheme == "mbox"
       raise ArgumentError, "mbox URI ('#{uri}') cannot have a host: #{uri.host}" if uri.host
       raise ArgumentError, "mbox URI must have a path component" unless uri.path
-      @f = File.open uri.path
+      @f = File.open uri.path, 'rb:BINARY'
       @path = uri.path
     else
       @f = uri_or_fp
@@ -114,7 +114,7 @@ class Loader < Source
 
   def store_message date, from_email, &block
     need_blank = File.exists?(@filename) && !File.zero?(@filename)
-    File.open(@filename, "a") do |f|
+    File.open(@filename, "ab:BINARY") do |f|
       f.puts if need_blank
       f.puts "From #{from_email} #{date.rfc2822}"
       yield f
-- 
1.6.3.3

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel