diff --git a/trunk/ripnews/ripnews.rb b/trunk/ripnews/ripnews.rb index ef753f5..bb0b2fd 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.94 2005/02/01 19:35:49 ward Exp $ +# $Dwarf: ripnews.rb,v 1.95 2005/02/01 22:09:22 ward Exp $ # $Source$ # @@ -384,11 +384,8 @@ end def get_multi(subj, group) print "Fetching multipart article: #{subj}\n" - if @config[group]["TEMPDIR"] == nil or @config[group]["TEMPDIR"] == "" - body = @articles.get_group_body(subj) - - # should probably thread this too, but I never use this - + body = @articles.get_group_body_first(subj) + if UUEncode.is_uuencoded(body) or YEnc.is_yencoded(body) if UUEncode.is_uuencoded(body) filename = UUEncode.get_filename(body) print " filename #{filename}\n" @@ -396,8 +393,6 @@ def get_multi(subj, group) print " Skipping article...\n" return false end - print " UUDecoding...\n" - mode, filename, body = UUEncode.uudecode(body) elsif YEnc.is_yencoded(body) print "yencc\n" filename = YEnc.get_filename(body) @@ -406,52 +401,16 @@ def get_multi(subj, group) print " Skipping article...\n" return false end - print " YDecoding...\n" - begin - mode, filename, body = YEnc.ydecode(body) - rescue YencError - # XXX if there is a yenc problem I want the data so I can research it - output_data(subj, 0600, "YencProblem", body) - # XXX return succes even though it's not true - return true - rescue PermError - print "#{$!}\n" + end + + if @config[group]["TEMPDIR"] == nil or @config[group]["TEMPDIR"] == "" + bodyrest = @articles.get_group_body_rest(subj) + unless bodyrest print " Skipping article...\n" return false end + body.concat(bodyrest) else - print " Unknown encoding (not UU, not yEnc), skipping...\n" - return false - end - if mode == false - print " Decoding failed skipping article...\n" - return false - end - output_data(subj, mode, filename, body) - - # end of thread - - return true - else - body = @articles.get_group_body_first(subj) - if UUEncode.is_uuencoded(body) or YEnc.is_yencoded(body) - if UUEncode.is_uuencoded(body) - filename = UUEncode.get_filename(body) - print " filename #{filename}\n" - return false unless check_ext(group, filename, "m", subj) - unless check_ext(group, filename, "m", subj) - print " Skipping article...\n" - return false - end - elsif YEnc.is_yencoded(body) - print "yencc\n" - filename = YEnc.get_filename(body) - print "filename #{filename}\n" - unless check_ext(group, filename, "m", subj) - print " Skipping article...\n" - return false - end - end file = Tempfile.new("riptmp", @config[group]["TEMPDIR"]) body.collect{|x| file.print "#{x}\n"} @@ -460,24 +419,44 @@ def get_multi(subj, group) return false end fileout = Tempfile.new("riptmp", @config[group]["TEMPDIR"]) + end - # I think a thread should start about here - @decode_threads << Thread.new(body, file, fileout, subj) do |tbody, tfile,tfileout, tsubj| - # imediately stop to continue with main program - Thread.stop - puts "inside thread\n" - if UUEncode.is_uuencoded(tbody) - print " UUDecoding...\n" - mode, filename, body = UUEncode.uudecode(tfile, tfileout) - elsif YEnc.is_yencoded(body) - print " YDecoding...\n" - mode, filename, body = YEnc.ydecode(tfile, tfileout) + @decode_threads << Thread.new(body, file, fileout, subj) do |tbody, tfile, tfileout, tsubj| + # imediately stop to continue with main program + Thread.stop + puts "inside thread\n" + if UUEncode.is_uuencoded(tbody) + print " UUDecoding...\n" + if tfile + mode, filename, tbody = UUEncode.uudecode(tfile, tfileout) + else + mode, filename, tbody = UUEncode.uudecode(tbody) end - if mode == false - print " Decoding failed skipping article...\n" + elsif YEnc.is_yencoded(tbody) + print " YDecoding...\n" + begin + if tfile + mode, filename, tbody = YEnc.ydecode(tfile, tfileout) + else + mode, filename, tbody = YEnc.ydecode(tbody) + end + rescue YencError + # XXX if there is a yenc problem I want the data so I can research it + output_data(subj, 0600, "YencProblem", tbody) + # XXX return succes even though it's not true + return true + rescue PermError + print "#{$!}\n" + print " Skipping article...\n" return false end - + end + if mode == false + print " Decoding failed skipping article...\n" + return false + end + + if tfile # horrible cheat to not lose the outputted file tbody = tfileout.path bodybase = tbody.sub(/\/[^\/]*$/, "/ripnewsdecode") @@ -487,29 +466,27 @@ def get_multi(subj, group) end File.move(tbody, "#{bodybase}-#{i}") tbody = "#{bodybase}-#{i}" - file.close - fileout.close(false) - - output_data(tsubj, mode, filename, tbody) + tfile.close + tfileout.close(false) end - # thread could end here + output_data(tsubj, mode, filename, tbody) + end # thread end - @decode_threads.each{ |thr| - if thr.status == "sleep" # and fire up the threads again - thr.run - elsif thr.status == "false" # remove finished threads - thr.join - else - p thr.status - end - } - puts "ouside thread\n" + @decode_threads.each{ |thr| + if thr.status == "sleep" # and fire up the threads again + thr.run + elsif thr.status == "false" # remove finished threads + thr.join + else + p thr.status + end + } + puts "ouside thread\n" - return true - else - print " Unknown encoding (not UU, not yEnc), skipping...\n" - return false - end + return true + else + print " Unknown encoding (not UU, not yEnc), skipping...\n" + return false end end