From 3ba2d5d731d76f16dc5f3003b6e061cf1d60f4a6 Mon Sep 17 00:00:00 2001 From: wmorgan Date: Mon, 4 Jun 2007 04:53:32 +0000 Subject: [PATCH] add locking to sup-sync-back git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@433 5c8cc53c-5e98-4d25-b20a-d8db53a31250 --- bin/sup-sync-back | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/bin/sup-sync-back b/bin/sup-sync-back index 46977e0..871af88 100644 --- a/bin/sup-sync-back +++ b/bin/sup-sync-back @@ -44,21 +44,24 @@ end Redwood::start index = Redwood::Index.new -index.load - -sources = ARGV.map do |uri| - s = index.source_for(uri) or Trollop::die "Unknown source: #{uri}. Did you add it with sup-add first?" - s.is_a?(Redwood::MBox::Loader) or Trollop::die "#{uri} is not an mbox source." - s -end +index.lock_or_die +deleted_fp, spam_fp = nil unless opts[:dry_run] deleted_fp = File.open(opts[:move_deleted], "a") if opts[:move_deleted] spam_fp = File.open(opts[:move_spam], "a") if opts[:move_spam] end -any_modified = false begin + index.load + + sources = ARGV.map do |uri| + s = index.source_for(uri) or Trollop::die "Unknown source: #{uri}. Did you add it with sup-add first?" + s.is_a?(Redwood::MBox::Loader) or Trollop::die "#{uri} is not an mbox source." + s + end + + any_modified = false sources.each { |s| s.reset! } sources.each do |source| @@ -123,5 +126,7 @@ rescue Exception => e File.open("sup-exception-log.txt", "w") { |f| f.puts e.backtrace } raise ensure + index.save Redwood::finish + index.unlock end -- 2.45.2