From 638c945a55d7baae7f769e2a828be815b4caf280 Mon Sep 17 00:00:00 2001 From: Ward Wouts Date: Mon, 16 Jun 2003 21:35:15 +0000 Subject: [PATCH] restructure a bit to make threading easier --- trunk/ripnews/ripnews.rb | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/trunk/ripnews/ripnews.rb b/trunk/ripnews/ripnews.rb index 9634c77..27f1886 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.64 2003/06/15 22:01:43 ward Exp $ +# $Dwarf: ripnews.rb,v 1.65 2003/06/16 10:56:11 ward Exp $ # $Source$ require 'date' @@ -290,7 +290,8 @@ def get_single(subj, group) print " Unknown encoding (not UU, not yEnc), skipping...\n" return false end - return mode, filename, body + output_data(i, mode, filename, body) + return true end def get_multi(subj, group) @@ -314,7 +315,8 @@ def get_multi(subj, group) print " Unknown encoding (not UU, not yEnc), skipping...\n" return false end - return mode, filename, body + output_data(i, mode, filename, body) + return true else body = @articles.get_group_body_first(subj) if UUEncode.is_uuencoded(body) or YEnc.is_yencoded(body) @@ -339,13 +341,21 @@ def get_multi(subj, group) print " YDecoding...\n" mode, filename, body = YEnc.ydecode(file, fileout) end + + # horrible cheat to not lose the outputted file body = fileout.path - bodybase = body.sub(/\/[^\/]*$/, "") - File.move(body, "#{bodybase}/ripnewsdecode") - body = "#{bodybase}/ripnewsdecode" + bodybase = body.sub(/\/[^\/]*$/, "/ripnewsdecode") + i = 1 + while Filetest.exists?("#{bodybase}-#{i}") + i += 1 + end + File.move(body, "#{bodybase}-#{i}") + body = "#{bodybase}-#{i}" file.close fileout.close(false) - return mode, filename, body + + output_data(i, mode, filename, body) + return true else print " Unknown encoding (not UU, not yEnc), skipping...\n" return false @@ -472,13 +482,7 @@ end for group in @config.keys.sort print "\nGetting articles for #{group}\n" @articles = Article.new(@config[group]["NNTPSERVER"], group, @config[group]["NEWSRCNAME"]) -# begin - @articles.get_articles(@config[group]["CACHEDIR"]) -# rescue Article:: -# print "Caught something: #{$!}\n" -# @articles.quit -# next -# end + @articles.get_articles(@config[group]["CACHEDIR"]) unless FileTest.directory?("#{@config[group]["DATADIR"]}/#{group}") or Dir.mkdir("#{@config[group]["DATADIR"]}/#{group}", @config[group]["PERMISSION"].oct) @@ -498,14 +502,12 @@ for group in @config.keys.sort if @articles.group_is_complete(i) begin if @articles.group_is_singlepart(i) - mode, filename, body = get_single(i, group) + succes = get_single(i, group) elsif @articles.group_is_multipart(i) - mode, filename, body = get_multi(i, group) + succes = get_multi(i, group) end - if mode == false + if succes == false print " Skipping article...\n" - else - output_data(i, mode, filename, body) end rescue Article::TempError, Article::PermError print "#{$!}\n"