From: wmorgan Date: Sat, 7 Jul 2007 14:30:49 +0000 (+0000) Subject: per-source short-circuit in sup-sync-back if there are no relevant messages X-Git-Url: https://git.notmuchmail.org/git?a=commitdiff_plain;h=72dffcb5fa9f57e4baa12ab7c791986a2617bebb;p=sup 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 --- diff --git a/bin/sup-sync-back b/bin/sup-sync-back index d61f219..808f10f 100644 --- 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 index 9ce4858..330b8a0 100644 --- 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