@@ -339,12 +339,23 @@ if {![_verifySignatureAndCertificate $hostname $indexhashcert $indexhashsig $indexhash]} { return -code error "Invalid signature or certificate from $hostname" } set file [download $hostname $indexhash] - set fd [open $file] - set data [read $fd] + catch { + set fd [open $file] + } + + if {![info exists fd]} { + return -code error "Unable to download or open $file" + } + + unset -nocomplain data + catch { + set data [read $fd] + } + close $fd set curr_packages [list] foreach line [split $data "\n"] { set line [string trim $line] @@ -422,12 +433,23 @@ if {![_isHash $package_sha1]} { return FAIL } set file [download $hostname $package_sha1] - set fd [open $file] - set pkgdata [read $fd] + + catch { + set fd [open $file] + } + + if {![info exists fd]} { + return -code error "Unable to download or open $file" + } + + catch { + set pkgdata [read $fd] + } + close $fd db transaction { foreach line [split $pkgdata "\n"] { set line [string trim $line]