a bit better handling of disappearing articles on a server.

it should now try the next server (if there is one)
not very well tested (euh, i haven't even tried to run it)

remove some debugging stuff that's no longer necessary
This commit is contained in:
Ward Wouts 2002-05-08 10:57:05 +00:00
parent d37aaf4c4a
commit 1b4dfd7464
2 changed files with 45 additions and 38 deletions

View file

@ -20,7 +20,6 @@ def initialize(nntpservers, groupname, newsrc="~/.newsrc")
@sorted = false
@grouped = false
#@skip_ids = Set::IntSpan.new()
@groups = {}
@gotten = {}
@group = groupname
@ -34,7 +33,6 @@ def initialize(nntpservers, groupname, newsrc="~/.newsrc")
@connections[server]["newsrc"] = News::Newsrc.new("#{newsrc}.#{server}")
set_skip_ids(server, @connections[server]["newsrc"].marked_articles(@group))
}
#@nntp = Net::NNTP.new(nntpservers)
end
def add(messid, id, server, subject)
@ -142,13 +140,19 @@ def get_group_body(subj)
group_subject_sort(subj)
for i in (0...@groups[subj]["messages"].length)
unless @gotten.has_key?(@groups[subj]["messages"][i])
print "getting article: #{i}\n" if Debuglevel > 0
print "getting article: #{i}\n" if Debuglevel > 1
begin
print "Server: #{@groups[subj]["servers"][i]}\n"
print "Messid: #{@groups[subj]["messages"][i]}\n"
resp, id, messid, list = @connections[@groups[subj]["servers"][i]]["nntp"].body(@groups[subj]["messages"][i])
rescue Net::NNTPReplyError
print "Caught Net::NNTPReplyError in get_group_body reading article #{@groups[subj]["messages"][0]}\n"
if (i+1 < @groups[subj]["messages"].length) and
(@groups[subj]["messages"][i] == @groups[subj]["messages"][i+1])
print "Trying next server\n"
next
end
return false
end
result = list
end
@ -158,18 +162,27 @@ end
def get_group_body_first(subj)
group_subject_sort(subj)
i = 0
while @gotten[messid] == false
begin
resp, id, messid, list = @connections[@groups[subj]["servers"][0]]["nntp"].body(@groups[subj]["messages"][0])
resp, id, messid, list = @connections[@groups[subj]["servers"][i]]["nntp"].body(@groups[subj]["messages"][i])
@gotten[messid] = true
rescue Net::NNTPReplyError
print "Caught Net::NNTPReplyError in get_group_body_first reading article #{@groups[subj]["messages"][0]}\n"
if (i+1 < @groups[subj]["messages"].length) and
(@groups[subj]["messages"][i] == @groups[subj]["messages"][i+1])
print "Trying next server\n"
i += 1
next
end
return false
end
end
print "getting article: #{subj}\n" if Debuglevel > 0
print "full subject: #{@groups[subj]["subject"][0]}\n" if Debuglevel > 0
print "message id: #{messid}\n" if Debuglevel > 0
print "id: #{id}\n" if Debuglevel > 0
print "server: #{@groups[subj]["servers"][0]}\n" if Debuglevel > 0
print "full subject: #{@groups[subj]["subject"][0]}\n" if Debuglevel > 0
@gotten[messid] = true
return list
end
@ -177,7 +190,7 @@ def get_group_body_rest(subj, file=nil)
result = []
for i in (1...@groups[subj]["messages"].length)
unless @gotten.has_key?(@groups[subj]["messages"][i])
print "getting article: #{i}\n" if Debuglevel > 0
print "getting article: #{i}\n" if Debuglevel > 1
begin
print "Server: #{@groups[subj]["servers"][i]}\n"
print "Messid: #{@groups[subj]["messages"][i]}\n"
@ -187,13 +200,18 @@ def get_group_body_rest(subj, file=nil)
end
rescue Net::NNTPReplyError
print "Caught Net::NNTPReplyError in get_group_body_rest reading article #{@groups[subj]["messages"][0]}\n"
if (i+1 < @groups[subj]["messages"].length) and
(@groups[subj]["messages"][i] == @groups[subj]["messages"][i+1])
print "Trying next server\n"
next
end
return false
end
print "getting article: #{subj}\n" if Debuglevel > 0
print "getting article: #{subj}\n" if Debuglevel > 1
print "full subject: #{@groups[subj]["subject"][i]}\n" if Debuglevel > 0
print "message id: #{messid}\n" if Debuglevel > 0
print "id: #{id}\n" if Debuglevel > 0
print "server: #{@groups[subj]["servers"][i]}\n" if Debuglevel > 0
print "full subject: #{@groups[subj]["subject"][i]}\n" if Debuglevel > 0
@gotten[ @groups[subj]["messages"][i] ] = true
if file
list.collect{|line| file.print "#{line}\n"}
@ -283,8 +301,6 @@ end
def group_update_newsrc(subject)
for i in (0...@groups[subject]["messages"].length)
# print "server: #{@groups[subject]["servers"][i]}\n"
# print "id: #{@groups[subject]["ids"][i]}\n"
@connections[@groups[subject]["servers"][i]]["newsrc"].mark(@group, @groups[subject]["ids"][i])
end
end
@ -306,14 +322,7 @@ def read_cache(cachedir)
file = File.new( filename )
lines = file.readlines
lines.collect{|line|
#print "line: #{line}\n"
if line =~ /^(\d+)\|(.*?)\|(.*?)\|(.*)$/
#print "id: #{$1}\n"
#print "messid: #{$2}\n"
#print "server: #{$3}\n"
#print "subject: #{$4}\n"
#print "First: #{@connections[$3]["first"].to_i}\n";
#print "Last: #{@connections[$3]["last"].to_i}\n";
if @connections.has_key?($3)
unless excludes.has_key?($3) and excludes[$3].has_key?($1.to_i) or
$1.to_i < @connections[$3]["first"].to_i or
@ -486,7 +495,6 @@ def uudecode_group(subj, tempdir=nil)
body = get_group_body_first(subj)
if body.to_s =~ /begin/
print "uuencoded!\n" if Debuglevel > 0
#if (file and outfile)
if (tempdir != nil)
file = Tempfile.new("#{tempdir}/riptmp")
body.collect{|i| file.print "#{i}\n"}
@ -835,7 +843,6 @@ def rechunk_runlist(runlist)
blup = blalist.join(",")
return blup
}
return
end

View file

@ -255,7 +255,7 @@ def get_multi(subj, group)
fileout.close
return mode, filename, body
end
print "unknown encoding (not UU, not yEnc), skipping...\n"
print " Unknown encoding (not UU, not yEnc), skipping...\n"
return false
end
end