sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 72dffcb5fa9f57e4baa12ab7c791986a2617bebb
parent cb2a359d3d7ed9f55296c197327cfdb63ad767e5
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date:   Sat,  7 Jul 2007 14:30:49 +0000

per-source short-circuit in sup-sync-back if there are no relevant messages

git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@480 5c8cc53c-5e98-4d25-b20a-d8db53a31250

Diffstat:
M bin/sup-sync-back | 6 ++++++
M lib/sup/index.rb | 7 +++++++
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/bin/sup-sync-back b/bin/sup-sync-back
@@ -66,6 +66,12 @@ begin
   
   sources.each do |source|
     $stderr.puts "Scanning #{source}..."
+
+    unless ((opts[:delete_deleted] || opts[:move_deleted]) && index.has_any_from_source_with_label?(source, :deleted)) || ((opts[:delete_spam] || opts[:move_spam]) && index.has_any_from_source_with_label?(source, :spam))
+      $stderr.puts "Nothing to do from this source; skipping"
+      next
+    end
+
     source.reset!
     num_deleted = num_moved = num_scanned = 0
     
diff --git a/lib/sup/index.rb b/lib/sup/index.rb
@@ -350,6 +350,13 @@ EOS
     @sources_dirty = false
   end
 
+  def has_any_from_source_with_label? source, label
+    q = Ferret::Search::BooleanQuery.new
+    q.add_query Ferret::Search::TermQuery.new("source_id", source.id.to_s), :must
+    q.add_query Ferret::Search::TermQuery.new("label", label.to_s), :must
+    num_results_for(:qobj => q) > 0
+  end
+
 protected
 
   def parse_user_query_string str; @qparser.parse str; end