lib/sup/maildir.rb in sup-0.9.1 vs lib/sup/maildir.rb in sup-0.10
- old
+ new
@@ -57,11 +57,11 @@
sleep 2 if File.stat(tmp_path)
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') do |f|
yield f #provide a writable interface for the caller
f.fsync
end
File.link tmp_path, new_path
@@ -185,10 +185,12 @@
def mark_passed msg; maildir_mark_file msg, "P" unless passed? msg; end
def mark_replied msg; maildir_mark_file msg, "R" unless replied? msg; end
def mark_seen msg; maildir_mark_file msg, "S" unless seen? msg; end
def mark_trashed msg; maildir_mark_file msg, "T" unless trashed? msg; end
+ def filename_for_id id; @ids_to_fns[id] end
+
private
def make_id fn
#doing this means 1 syscall instead of 2 (File.mtime, File.size).
#makes a noticeable difference on nfs.
@@ -203,10 +205,10 @@
end
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') { |f| yield f }
rescue SystemCallError, IOError => e
raise FatalSourceError, "Problem reading file for id #{id.inspect}: #{fn.inspect}: #{e.message}."
end
end