restructure a bit to make threading easier
This commit is contained in:
parent
5998913c87
commit
638c945a55
1 changed files with 21 additions and 19 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/local/bin/ruby -w
|
#!/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$
|
# $Source$
|
||||||
|
|
||||||
require 'date'
|
require 'date'
|
||||||
|
|
@ -290,7 +290,8 @@ def get_single(subj, group)
|
||||||
print " Unknown encoding (not UU, not yEnc), skipping...\n"
|
print " Unknown encoding (not UU, not yEnc), skipping...\n"
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return mode, filename, body
|
output_data(i, mode, filename, body)
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_multi(subj, group)
|
def get_multi(subj, group)
|
||||||
|
|
@ -314,7 +315,8 @@ def get_multi(subj, group)
|
||||||
print " Unknown encoding (not UU, not yEnc), skipping...\n"
|
print " Unknown encoding (not UU, not yEnc), skipping...\n"
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return mode, filename, body
|
output_data(i, mode, filename, body)
|
||||||
|
return true
|
||||||
else
|
else
|
||||||
body = @articles.get_group_body_first(subj)
|
body = @articles.get_group_body_first(subj)
|
||||||
if UUEncode.is_uuencoded(body) or YEnc.is_yencoded(body)
|
if UUEncode.is_uuencoded(body) or YEnc.is_yencoded(body)
|
||||||
|
|
@ -339,13 +341,21 @@ def get_multi(subj, group)
|
||||||
print " YDecoding...\n"
|
print " YDecoding...\n"
|
||||||
mode, filename, body = YEnc.ydecode(file, fileout)
|
mode, filename, body = YEnc.ydecode(file, fileout)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# horrible cheat to not lose the outputted file
|
||||||
body = fileout.path
|
body = fileout.path
|
||||||
bodybase = body.sub(/\/[^\/]*$/, "")
|
bodybase = body.sub(/\/[^\/]*$/, "/ripnewsdecode")
|
||||||
File.move(body, "#{bodybase}/ripnewsdecode")
|
i = 1
|
||||||
body = "#{bodybase}/ripnewsdecode"
|
while Filetest.exists?("#{bodybase}-#{i}")
|
||||||
|
i += 1
|
||||||
|
end
|
||||||
|
File.move(body, "#{bodybase}-#{i}")
|
||||||
|
body = "#{bodybase}-#{i}"
|
||||||
file.close
|
file.close
|
||||||
fileout.close(false)
|
fileout.close(false)
|
||||||
return mode, filename, body
|
|
||||||
|
output_data(i, mode, filename, body)
|
||||||
|
return true
|
||||||
else
|
else
|
||||||
print " Unknown encoding (not UU, not yEnc), skipping...\n"
|
print " Unknown encoding (not UU, not yEnc), skipping...\n"
|
||||||
return false
|
return false
|
||||||
|
|
@ -472,13 +482,7 @@ end
|
||||||
for group in @config.keys.sort
|
for group in @config.keys.sort
|
||||||
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
|
@articles.get_articles(@config[group]["CACHEDIR"])
|
||||||
@articles.get_articles(@config[group]["CACHEDIR"])
|
|
||||||
# rescue Article::
|
|
||||||
# print "Caught something: #{$!}\n"
|
|
||||||
# @articles.quit
|
|
||||||
# next
|
|
||||||
# end
|
|
||||||
|
|
||||||
unless FileTest.directory?("#{@config[group]["DATADIR"]}/#{group}") or
|
unless FileTest.directory?("#{@config[group]["DATADIR"]}/#{group}") or
|
||||||
Dir.mkdir("#{@config[group]["DATADIR"]}/#{group}", @config[group]["PERMISSION"].oct)
|
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)
|
if @articles.group_is_complete(i)
|
||||||
begin
|
begin
|
||||||
if @articles.group_is_singlepart(i)
|
if @articles.group_is_singlepart(i)
|
||||||
mode, filename, body = get_single(i, group)
|
succes = get_single(i, group)
|
||||||
elsif @articles.group_is_multipart(i)
|
elsif @articles.group_is_multipart(i)
|
||||||
mode, filename, body = get_multi(i, group)
|
succes = get_multi(i, group)
|
||||||
end
|
end
|
||||||
if mode == false
|
if succes == false
|
||||||
print " Skipping article...\n"
|
print " Skipping article...\n"
|
||||||
else
|
|
||||||
output_data(i, mode, filename, body)
|
|
||||||
end
|
end
|
||||||
rescue Article::TempError, Article::PermError
|
rescue Article::TempError, Article::PermError
|
||||||
print "#{$!}\n"
|
print "#{$!}\n"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue