From 64d3e59cbb52b08ee678a2989d7287aa80d2423e Mon Sep 17 00:00:00 2001 From: Ward Wouts Date: Sun, 24 Feb 2008 18:20:07 +0000 Subject: [PATCH] nieuwe groups werden niet gesaved --- trunk/ripnews/news/newsrc.rb | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/trunk/ripnews/news/newsrc.rb b/trunk/ripnews/news/newsrc.rb index 17117d5..86cb2b7 100644 --- a/trunk/ripnews/news/newsrc.rb +++ b/trunk/ripnews/news/newsrc.rb @@ -139,15 +139,15 @@ end # If not, mutexes are needed. def save_group_as(file, group) # @@save_lock.synchronize{ -p Time.now -p "copy file" +#p Time.now +#p "copy file" if FileTest.exists?("#{file}") if ( ! File.copy(file, "#{file}.bak") ) puts "Can't copy #{file} to #{file}.bak: #{$!}" end end -p Time.now -p "open & lock file" +#p Time.now +#p "open & lock file" begin newsrc = File.new(file, "r+") newsrc.flock(File::LOCK_EX) @@ -155,8 +155,8 @@ p "open & lock file" puts "Can't open ${file}: #{$!}" exit end -p Time.now -p "opened & locked" +#p Time.now +#p "opened & locked" # read file lines = newsrc.readlines @@ -164,6 +164,7 @@ p "opened & locked" # pointer -> 0 newsrc.rewind + group_saved = false # write read stuff & replace group lines.each{|line| # same parsing as the parse method uses @@ -179,13 +180,17 @@ p "opened & locked" linegroup = $1 if linegroup == group["name"] newsrc.print format(group) + group_saved = true else newsrc.print line end } + if ! group_saved + newsrc.print format(group) + end -p Time.now -p "truncate, sync, unlock & close file" +#p Time.now +#p "truncate, sync, unlock & close file" # sometimes the file grows and then shrinks # this is because a 'read' line van become shorter when more # articles have been read (1,3,5 vs 1-5) @@ -195,9 +200,9 @@ p "truncate, sync, unlock & close file" newsrc.sync newsrc.flock(File::LOCK_UN) # what's the right order here? newsrc.close -p Time.now -p "garbage collect" -p Time.now +#p Time.now +#p "garbage collect" +#p Time.now GC.start # } end