]> git.cworth.org Git - sup/blobdiff - lib/sup/sent.rb
bugfix: multiple full header views would overwrite each other
[sup] / lib / sup / sent.rb
index 37b9524db36c345c11c58ef7db4af8e92eabd90b..9c802d9673a4247cff3f0a999b262cfc8edc495e 100644 (file)
@@ -12,7 +12,7 @@ class SentManager
 
   def self.source_name; "sup://sent"; end
   def self.source_id; 9998; end
-  def new_source; @source = SentLoader.new; end
+  def new_source; @source = Recoverable.new SentLoader.new; end
 
   def write_sent_message date, from_email
     need_blank = File.exists?(@fn) && !File.zero?(@fn)
@@ -21,27 +21,30 @@ class SentManager
       f.puts "From #{from_email} #{date}"
       yield f
     end
+
     @source.each do |offset, labels|
       m = Message.new :source => @source, :source_info => offset, :labels => @source.labels
       Index.sync_message m
-      UpdateManager.relay self, :add, m
+      UpdateManager.relay self, :added, m
     end
   end
 end
 
 class SentLoader < MBox::Loader
+  yaml_properties :cur_offset
+
   def initialize cur_offset=0
-    filename = Redwood::SENT_FN
-    File.open(filename, "w") { } unless File.exists? filename
-    super "mbox://" + filename, cur_offset, true, true
+    @filename = Redwood::SENT_FN
+    File.open(@filename, "w") { } unless File.exists? @filename
+    super "mbox://" + @filename, cur_offset, true, true
   end
 
+  def file_path; @filename end
+
   def uri; SentManager.source_name; end
   def to_s; SentManager.source_name; end
   def id; SentManager.source_id; end
   def labels; [:sent, :inbox]; end
 end
 
-Redwood::register_yaml(SentLoader, %w(cur_offset))
-
 end