commit 4f4f6f7bdbc71832fd8da0af1e9fbed6ea5dcdd9 parent 419dece4e2c36a40373abaeb13c923b0dc06b96f Author: Luxferre <lux@ferre> Date: Sun, 27 Oct 2024 15:16:42 +0200 Added retry logic to fetching process Diffstat:
M | tiifetch.tcl | | | 15 | +++++++++++++-- |
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/tiifetch.tcl b/tiifetch.tcl @@ -290,8 +290,19 @@ proc fetchiidb {url echos dbfile dolog maxids} { if {$dolog eq 1} {puts "Fetching $globalcount new messages from $echoname..."} dict for {mgrpind mgrp} $idgroups { # iterate over groups to fetch the messages # get the message data in the bundle format - set msgbundle [getfile [string cat $url "/u/m/" [join $mgrp "/"]]] - set bdata [split $msgbundle "\n"] + set plen 0 + set retries 4 + while {$plen < $globalcount} { + set msgbundle [getfile [string cat $url "/u/m/" [join $mgrp "/"]]] + set bdata [lmap m [split $msgbundle "\n"] { + set m [string trim $m] + if {$m eq ""} {continue} + set m + }] + set plen [llength $bdata] + incr retries -1 + if {$retries < 1} {break} + } foreach bline $bdata { set parts [split $bline ":"] if {[llength $parts] > 1} { # valid message