Fixed fetching algorithm
This commit is contained in:
+12
-3
@@ -176,6 +176,17 @@ proc writefileln {fname data} {
|
||||
close $fp
|
||||
}
|
||||
|
||||
# list comparison helper (listcomp $new $old)
|
||||
proc listcomp {a b} {
|
||||
set diff {}
|
||||
foreach i $a {
|
||||
if {[lsearch -exact $b $i]==-1} {
|
||||
lappend diff $i
|
||||
}
|
||||
}
|
||||
return $diff
|
||||
}
|
||||
|
||||
# main logic proc
|
||||
proc fetchiidb {url echos dbdir dolog} {
|
||||
# trim the parameters
|
||||
@@ -232,9 +243,7 @@ proc fetchiidb {url echos dbdir dolog} {
|
||||
set oldmsgids [lmap s [split [readfile $echofile] "\n"] {string trim $s}]
|
||||
}
|
||||
# pre-filter the new message IDs to fetch
|
||||
set newmsgids [concat $oldmsgids $msgids]
|
||||
foreach e $newmsgids {dict set tmp $e 1}
|
||||
set newmsgids [dict keys $tmp]
|
||||
set newmsgids [listcomp $msgids $oldmsgids]
|
||||
# save the echo index file with all message IDs
|
||||
writefileln $echofile [join $msgids "\n"]
|
||||
if {$dolog eq 1} {puts "Fetching [llength $newmsgids] new messages from $echoname..."}
|
||||
|
||||
Reference in New Issue
Block a user