]> git.cworth.org Git - sup/commitdiff
make sup-sync-back short-circuit work properly
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Sat, 7 Jul 2007 15:05:05 +0000 (15:05 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Sat, 7 Jul 2007 15:05:05 +0000 (15:05 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@482 5c8cc53c-5e98-4d25-b20a-d8db53a31250

bin/sup-sync-back
lib/sup/index.rb

index 808f10f4f50df34644af4b76665af8de61b66090..c27f1922f84a34d636aeeb150a54466ecf0e1405 100644 (file)
@@ -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
index 330b8a00f4035be95f34876b6ac2d059caf45787..731946890d5693e643b5d62e0efc5b47279a5eba 100644 (file)
@@ -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