Fixed fetching algorithm
This commit is contained in:
+12
-3
@@ -176,6 +176,17 @@ proc writefileln {fname data} {
|
|||||||
close $fp
|
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
|
# main logic proc
|
||||||
proc fetchiidb {url echos dbdir dolog} {
|
proc fetchiidb {url echos dbdir dolog} {
|
||||||
# trim the parameters
|
# trim the parameters
|
||||||
@@ -232,9 +243,7 @@ proc fetchiidb {url echos dbdir dolog} {
|
|||||||
set oldmsgids [lmap s [split [readfile $echofile] "\n"] {string trim $s}]
|
set oldmsgids [lmap s [split [readfile $echofile] "\n"] {string trim $s}]
|
||||||
}
|
}
|
||||||
# pre-filter the new message IDs to fetch
|
# pre-filter the new message IDs to fetch
|
||||||
set newmsgids [concat $oldmsgids $msgids]
|
set newmsgids [listcomp $msgids $oldmsgids]
|
||||||
foreach e $newmsgids {dict set tmp $e 1}
|
|
||||||
set newmsgids [dict keys $tmp]
|
|
||||||
# save the echo index file with all message IDs
|
# save the echo index file with all message IDs
|
||||||
writefileln $echofile [join $msgids "\n"]
|
writefileln $echofile [join $msgids "\n"]
|
||||||
if {$dolog eq 1} {puts "Fetching [llength $newmsgids] new messages from $echoname..."}
|
if {$dolog eq 1} {puts "Fetching [llength $newmsgids] new messages from $echoname..."}
|
||||||
|
|||||||
@@ -211,10 +211,9 @@ proc tiix_fetchecho {echoname} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
global tiix_status localdbdir
|
global tiix_status localdbdir
|
||||||
set prev_status $tiix_status
|
|
||||||
set tiix_status "Fetching echo contents..."
|
set tiix_status "Fetching echo contents..."
|
||||||
massfetch $echoname $localdbdir 0
|
massfetch $echoname $localdbdir 0
|
||||||
set tiix_status $prev_status
|
set tiix_status Ready
|
||||||
}
|
}
|
||||||
|
|
||||||
proc errmsg {msg} {
|
proc errmsg {msg} {
|
||||||
|
|||||||
Reference in New Issue
Block a user