diff --git a/tiifetch.tcl b/tiifetch.tcl index e6231fc..24a5f75 100755 --- 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