From bc8f615d72bf9ecabf769762f5825f0f358cc73d Mon Sep 17 00:00:00 2001 From: wmorgan Date: Sat, 7 Jul 2007 15:05:05 +0000 Subject: [PATCH] make sup-sync-back short-circuit work properly git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@482 5c8cc53c-5e98-4d25-b20a-d8db53a31250 --- bin/sup-sync-back | 17 +++++++++++++++-- lib/sup/index.rb | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/bin/sup-sync-back b/bin/sup-sync-back index 808f10f..c27f192 100644 --- a/bin/sup-sync-back +++ b/bin/sup-sync-back @@ -60,7 +60,14 @@ begin s.is_a?(Redwood::MBox::Loader) or Trollop::die "#{uri} is not an mbox source." s end - sources = index.usual_sources.select { |s| s.is_a? Redwood::MBox::Loader } if sources.empty? + + using_usual_sources = + if sources.empty? + sources = index.usual_sources.select { |s| s.is_a? Redwood::MBox::Loader } + true + else + false + end any_modified = false @@ -129,7 +136,13 @@ begin end $stderr.puts "Done." - $stderr.puts "You should now run: sup-sync --changed #{sources.join(' ')}" if any_modified + if any_modified + if using_usual_sources + $stderr.puts "You should now run: sup-sync --changed #{sources.join(' ')}" + else + $stderr.puts "You should now run: sup-sync --changed" + end + end rescue Exception => e File.open("sup-exception-log.txt", "w") { |f| f.puts e.backtrace } raise diff --git a/lib/sup/index.rb b/lib/sup/index.rb index 330b8a0..7319468 100644 --- a/lib/sup/index.rb +++ b/lib/sup/index.rb @@ -354,7 +354,7 @@ EOS 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 + index.search(q, :limit => 1).total_hits > 0 end protected -- 2.45.2