better error handling
This commit is contained in:
parent
0154d6292d
commit
9026140c4e
2 changed files with 89 additions and 97 deletions
|
|
@ -224,7 +224,6 @@ def get_multi(subj, group)
|
|||
return false
|
||||
else
|
||||
body = @articles.get_group_body_first(subj)
|
||||
return false if body == false
|
||||
if @articles.is_uuencoded(body) or @articles.is_yencoded(body)
|
||||
file = Tempfile.new("riptmp", @config[group]["TEMPDIR"])
|
||||
body.collect{|x| file.print "#{x}\n"}
|
||||
|
|
@ -248,28 +247,23 @@ def get_multi(subj, group)
|
|||
end
|
||||
|
||||
def output_data(subject, mode, filename="", body="")
|
||||
if mode
|
||||
group = @articles.get_groupname
|
||||
print " mode: #{mode}\n" if Debuglevel > 0
|
||||
print " Filename: '#{filename}'\n" if Debuglevel > 0
|
||||
if @config[group].has_key?("-L") and @config[group]["-L"]
|
||||
print "longname\n" if Debuglevel > 1
|
||||
outfile = subject
|
||||
elsif @config[group].has_key?("-C") and @config[group]["-C"]
|
||||
print "combinedname\n" if Debuglevel > 1
|
||||
outfile = "#{subject} [#{filename}]"
|
||||
else
|
||||
print "shortname\n" if Debuglevel > 1
|
||||
outfile = filename
|
||||
end
|
||||
if save_file("#{@config[group]["DATADIR"]}/#{group}", outfile, body)
|
||||
@articles.group_update_newsrc(subject)
|
||||
@articles.save_newsrc unless @config[group].has_key?("-T") and @config[group]["-T"]
|
||||
end
|
||||
group = @articles.get_groupname
|
||||
print " mode: #{mode}\n" if Debuglevel > 0
|
||||
print " Filename: '#{filename}'\n" if Debuglevel > 0
|
||||
if @config[group].has_key?("-L") and @config[group]["-L"]
|
||||
print "longname\n" if Debuglevel > 1
|
||||
outfile = subject
|
||||
elsif @config[group].has_key?("-C") and @config[group]["-C"]
|
||||
print "combinedname\n" if Debuglevel > 1
|
||||
outfile = "#{subject} [#{filename}]"
|
||||
else
|
||||
return false
|
||||
print "shortname\n" if Debuglevel > 1
|
||||
outfile = filename
|
||||
end
|
||||
if save_file("#{@config[group]["DATADIR"]}/#{group}", outfile, body)
|
||||
@articles.group_update_newsrc(subject)
|
||||
@articles.save_newsrc unless @config[group].has_key?("-T") and @config[group]["-T"]
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
def check_ext(filename, mode)
|
||||
|
|
@ -303,10 +297,13 @@ end
|
|||
for group in @config.keys.sort
|
||||
print "Getting articles for #{group}\n"
|
||||
@articles = Article.new(@config[group]["NNTPSERVER"], group, @config[group]["NEWSRCNAME"])
|
||||
if @articles.get_articles(@config[group]["CACHEDIR"]) == false
|
||||
@articles.quit
|
||||
next
|
||||
end
|
||||
# begin
|
||||
@articles.get_articles(@config[group]["CACHEDIR"])
|
||||
# rescue Article::
|
||||
# print "Caught something: #{$!}\n"
|
||||
# @articles.quit
|
||||
# next
|
||||
# end
|
||||
|
||||
unless FileTest.directory?("#{@config[group]["DATADIR"]}/#{group}") or
|
||||
Dir.mkdir("#{@config[group]["DATADIR"]}/#{group}", @config[group]["PERMISSION"].oct)
|
||||
|
|
@ -319,12 +316,16 @@ for group in @config.keys.sort
|
|||
i =~ /#{@config[group]["-I"]}/
|
||||
print "Match: #{i}\n" if Debuglevel > 0
|
||||
if @articles.group_is_complete(i)
|
||||
if @articles.group_is_singlepart(i)
|
||||
mode, filename, body = get_single(i)
|
||||
elsif @articles.group_is_multipart(i)
|
||||
mode, filename, body = get_multi(i, group)
|
||||
begin
|
||||
if @articles.group_is_singlepart(i)
|
||||
mode, filename, body = get_single(i)
|
||||
elsif @articles.group_is_multipart(i)
|
||||
mode, filename, body = get_multi(i, group)
|
||||
end
|
||||
output_data(i, mode, filename, body) if mode != false
|
||||
rescue Article::BodyError
|
||||
next
|
||||
end
|
||||
output_data(i, mode, filename, body)
|
||||
else
|
||||
print " Not complete: #{i}\n"
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue