commit 7c594acbf14ce9126a66a098f1d78febb9f69b73
parent 8995621f4a1988a588a3c7fded914a18de08aac9
Author: Luxferre <lux@ferre>
Date: Wed, 23 Oct 2024 16:25:51 +0300
Fixed fetching algorithm
Diffstat:
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/tiifetch.tcl b/tiifetch.tcl
@@ -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..."}
diff --git a/tiix.tcl b/tiix.tcl
@@ -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} {