change order in cache files, so it's easier to sort the cache by ids

which makes the skip_ids structs use a lot less memory
This commit is contained in:
Ward Wouts 2002-05-07 07:45:00 +00:00
parent 00303569f2
commit 744ee0074e

View file

@ -149,7 +149,7 @@ def get_group_body(subj)
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 reading article #{@groups[subj]["messages"][0]}\n"
print "Caught Net::NNTPReplyError in get_group_body reading article #{@groups[subj]["messages"][0]}\n"
end
result = list
end
@ -162,7 +162,7 @@ def get_group_body_first(subj)
begin
resp, id, messid, list = @connections[@groups[subj]["servers"][0]]["nntp"].body(@groups[subj]["messages"][0])
rescue Net::NNTPReplyError
print "Caught Net::NNTPReplyError reading article #{@groups[subj]["messages"][0]}\n"
print "Caught Net::NNTPReplyError in get_group_body_first reading article #{@groups[subj]["messages"][0]}\n"
return false
end
print "getting article: #{subj}\n" if Debuglevel > 0
@ -187,7 +187,7 @@ def get_group_body_rest(subj, file=nil)
return false
end
rescue Net::NNTPReplyError
print "Caught Net::NNTPReplyError reading article #{@groups[subj]["messages"][0]}\n"
print "Caught Net::NNTPReplyError in get_group_body_rest reading article #{@groups[subj]["messages"][0]}\n"
return false
end
print "getting article: #{subj}\n" if Debuglevel > 0
@ -308,23 +308,24 @@ def read_cache(cachedir)
lines = file.readlines
lines.collect{|line|
#print "line: #{line}\n"
if line =~ /^(.*?)\|(\d+)\|(.*?)\|(.*)$/
#print "messid: #{$1}\n"
#print "id: #{$2}\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?($2.to_i) or
$2.to_i < @connections[$3]["first"].to_i or
$2.to_i > @connections[$3]["last"].to_i
add($1, $2, $3, $4)
@connections[$3]["skip_ids"].insert($2.to_i)
unless excludes.has_key?($3) and excludes[$3].has_key?($1.to_i) or
$1.to_i < @connections[$3]["first"].to_i or
$1.to_i > @connections[$3]["last"].to_i
add($2, $1, $3, $4)
@connections[$3]["skip_ids"].insert($1.to_i)
end
end
end
}
file.close
end
end
@ -332,10 +333,13 @@ def save_cache(cachedir)
filename = "#{cachedir}/#{@group}.ripnewscache"
if FileTest.directory?( cachedir )
file = File.new( filename, "w" ) or print "couldn't open cachefile for writing\n"
cache = []
for i in (0...@subjects.length)
file.print("#{@messids[i]}|#{@ids[i]}|#{@servers[i]}|#{@subjects[i]}\n")
#print "writing: #{@messids[i]}|#{@ids[i]}|#{@servers[i]}|#{@subjects[i]}\n"
cache += ["#{@ids[i]}|#{@messids[i]}|#{@servers[i]}|#{@subjects[i]}\n"]
end
cache.sort!
file.print cache
file.close
end
end