@@ -340,10 +340,21 @@ 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"] { @@ -423,10 +434,21 @@ 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"] {