Fixed fetching algorithm

This commit is contained in:
Luxferre
2024-10-23 16:25:51 +03:00
parent 8995621f4a
commit 7c594acbf1
2 changed files with 13 additions and 5 deletions
+12 -3
View File
@@ -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..."}
+1 -2
View File
@@ -211,10 +211,9 @@ proc tiix_fetchecho {echoname} {
}
}
global tiix_status localdbdir
set prev_status $tiix_status
set tiix_status "Fetching echo contents..."
massfetch $echoname $localdbdir 0
set tiix_status $prev_status
set tiix_status Ready
}
proc errmsg {msg} {