From 1eac2fa43d780decea05bff2b0f17f33b33f31d8 Mon Sep 17 00:00:00 2001 From: Ward Wouts Date: Sat, 24 May 2003 18:33:46 +0000 Subject: [PATCH] earlier exit when locked --- trunk/ripnews/ripnews.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/trunk/ripnews/ripnews.rb b/trunk/ripnews/ripnews.rb index f128a94..e991eda 100755 --- a/trunk/ripnews/ripnews.rb +++ b/trunk/ripnews/ripnews.rb @@ -1,6 +1,6 @@ #!/usr/local/bin/ruby -w -# $Dwarf: ripnews.rb,v 1.59 2003/04/28 21:52:48 ward Exp $ +# $Dwarf: ripnews.rb,v 1.60 2003/05/24 12:05:57 ward Exp $ # $Source$ require 'date' @@ -236,7 +236,8 @@ def check_config } end -def lock(group) +def lock + group = @config.keys[0] if @config[group].has_key?("LOCKFILE") if FileTest.exists?(@config[group]["LOCKFILE"]) # Should also detect stale locks here @@ -250,7 +251,8 @@ def lock(group) end end -def unlock(group) +def unlock + group = @config.keys[0] File.unlink(@config[group]["LOCKFILE"]) end @@ -415,6 +417,7 @@ defaults = {'-c' => "#{ENV['HOME']}/.ripnewsrc"} defaults = parse_options(defaults) parse_config(defaults) check_config +lock @maxfilelength = get_max_file_length(@config[@config.keys[0]]["TEMPDIR"]) @@ -432,7 +435,6 @@ if Debuglevel > 2 end for group in @config.keys.sort - lock(group) print "\nGetting articles for #{group}\n" @articles = Article.new(@config[group]["NNTPSERVER"], group, @config[group]["NEWSRCNAME"]) # begin @@ -481,7 +483,6 @@ for group in @config.keys.sort end end @articles.quit - unlock(group) end tend = Time.now @@ -492,3 +493,4 @@ m=runtime%3600 s=m%60 m=m/60 printf("Running time: %02d:%02d:%02d\n", h, m, s) +unlock