]> git.cworth.org Git - sup/blobdiff - lib/sup/sent.rb
per-source short-circuit in sup-sync-back if there are no relevant messages
[sup] / lib / sup / sent.rb
index b28c08d108d9b3849f8a2773e1c6dc8c2f92efb2..b4a57ec259ecade31aefdd97cb35f1d174076319 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)
@@ -23,25 +23,27 @@ class SentManager
     end
     @source.each do |offset, labels|
       m = Message.new :source => @source, :source_info => offset, :labels => @source.labels
-      Index.add_message m
+      Index.sync_message m
       UpdateManager.relay self, :add, 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