earlier exit when locked

This commit is contained in:
Ward Wouts 2003-05-24 18:33:46 +00:00
parent b1b1e431da
commit 1eac2fa43d

View file

@ -1,6 +1,6 @@
#!/usr/local/bin/ruby -w #!/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$ # $Source$
require 'date' require 'date'
@ -236,7 +236,8 @@ def check_config
} }
end end
def lock(group) def lock
group = @config.keys[0]
if @config[group].has_key?("LOCKFILE") if @config[group].has_key?("LOCKFILE")
if FileTest.exists?(@config[group]["LOCKFILE"]) if FileTest.exists?(@config[group]["LOCKFILE"])
# Should also detect stale locks here # Should also detect stale locks here
@ -250,7 +251,8 @@ def lock(group)
end end
end end
def unlock(group) def unlock
group = @config.keys[0]
File.unlink(@config[group]["LOCKFILE"]) File.unlink(@config[group]["LOCKFILE"])
end end
@ -415,6 +417,7 @@ defaults = {'-c' => "#{ENV['HOME']}/.ripnewsrc"}
defaults = parse_options(defaults) defaults = parse_options(defaults)
parse_config(defaults) parse_config(defaults)
check_config check_config
lock
@maxfilelength = get_max_file_length(@config[@config.keys[0]]["TEMPDIR"]) @maxfilelength = get_max_file_length(@config[@config.keys[0]]["TEMPDIR"])
@ -432,7 +435,6 @@ if Debuglevel > 2
end end
for group in @config.keys.sort for group in @config.keys.sort
lock(group)
print "\nGetting articles for #{group}\n" print "\nGetting articles for #{group}\n"
@articles = Article.new(@config[group]["NNTPSERVER"], group, @config[group]["NEWSRCNAME"]) @articles = Article.new(@config[group]["NNTPSERVER"], group, @config[group]["NEWSRCNAME"])
# begin # begin
@ -481,7 +483,6 @@ for group in @config.keys.sort
end end
end end
@articles.quit @articles.quit
unlock(group)
end end
tend = Time.now tend = Time.now
@ -492,3 +493,4 @@ m=runtime%3600
s=m%60 s=m%60
m=m/60 m=m/60
printf("Running time: %02d:%02d:%02d\n", h, m, s) printf("Running time: %02d:%02d:%02d\n", h, m, s)
unlock