add multipart/singlepart/uuencoded checks

simplify stuff
This commit is contained in:
Ward Wouts 2002-05-01 22:16:01 +00:00
parent 4da31a02dd
commit 773658d7ab

View file

@ -5,6 +5,7 @@
require 'set/intspan'
require 'net/nntp'
require 'tempfile'
class Article
@ -65,7 +66,7 @@ end
def get_group_body(subj)
result = []
for i in @groups[subj]["messages"][1..@groups[subj]["messages"].length]
for i in @groups[subj]["messages"][0..@groups[subj]["messages"].length]
begin
resp, id, messid, list = @nntp.body(i)
rescue Net::NNTPReplyError
@ -100,9 +101,7 @@ def get_group_body_rest(subj, file=nil)
return false
end
if file
for line in list
file.print "#{line}\n"
end
list.collect{|line| file.print "#{line}\n"}
else
result += list
end
@ -130,6 +129,14 @@ def group_complete(subj)
end
end
def group_singlepart(subj)
@groups[subj]["total"].to_i == 1
end
def group_multipart(subj)
@groups[subj]["total"].to_i > 1
end
def get_messids
return @messids
end
@ -302,9 +309,7 @@ def _uudecode_array(data)
mark = lines/100
i = 0
print "data.length #{data.length}\n"
while (i < data.length)
print "i #{i}\n"
if data[i] =~ /^begin(.*)/
m = $1
print "beginning matched; rest: #{m}\n" if Debuglevel > 0
@ -350,16 +355,17 @@ def _uudecode_array(data)
return mode, file, decode
end
def uudecode_group(subj, file=nil, outfile=nil)
#def uudecode_group(subj, file=nil, outfile=nil)
def uudecode_group(subj, tempdir=nil)
group_subjects unless @grouped
body = get_group_body_first(subj)
if body.to_s =~ /begin/
print "uuencoded!\n" if Debuglevel > 0
if (file and outfile)
for i in body
file.print "#{i}\n"
end
#if (file and outfile)
if (tempdir != nil)
file = Tempfile.new("#{tempdir}/riptmp")
body.collect{|i| file.print "#{i}\n"}
get_group_body_rest(subj, file)
mode, filename, result = uudecode(file, outfile)
else
@ -373,6 +379,14 @@ def uudecode_group(subj, file=nil, outfile=nil)
end
end
def is_uuencoded(data)
if data.to_s =~ /begin\s+\d+?\s+.*?\S?\s*\Z/
return true
else
return false
end
end
###############################################################
def subject_sort