diff options
author | B. Watson <yalhcru@gmail.com> | 2015-10-22 06:25:08 -0400 |
---|---|---|
committer | B. Watson <yalhcru@gmail.com> | 2015-10-22 06:25:08 -0400 |
commit | 470d963f883266ceb3f28fbb674c6dd4950d381a (patch) | |
tree | cb52f13f3781796cbc76672ffa4763bd067c05a2 | |
parent | e8cffa2fa006a26468f93685e8aa1dd187113621 (diff) | |
download | sbostuff-470d963f883266ceb3f28fbb674c6dd4950d381a.tar.gz |
sbosrcarch: show proper errors when curl fails and $maxfilemegs == 0
-rwxr-xr-x | sbosrcarch | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -638,10 +638,13 @@ sub curl_download_http { user_agent($url) . " -o'$filename' --retry 2 " . wget_quote_url($url) . + " -D $outfile.hdr " . " > $outfile 2>&1"; warn "* $cmd\n" if $DEBUG_HTTP; my $retval = system($cmd); + print "curl retval==$retval\n" if $DEBUG_HTTP; + if($retval != 0) { open my $fh, "<$outfile"; while(<$fh>) { @@ -649,6 +652,22 @@ sub curl_download_http { } } + open $fh, "<$outfile.hdr"; + while(<$fh>) { + $_ =~ s,[\r\n],,g; + next unless /^HTTP\/\S+\s+(\d+)/; + $httpstatusline = $_, $httpstatus = $1; + } + + unlink($outfile); + unlink("$outfile.hdr"); + + if($httpstatus ne "200") { + print "! $httpstatusline\n"; + unlink $filename; + return undef; + } + if(-f $filename) { $size = -s _; warn "* $filename exists, $size bytes\n" if $DEBUG_HTTP; @@ -1079,7 +1098,8 @@ sub handle_info_file { local $maxfilemegs = 0 if whitelisted($category, $prgnam); download_file($url); # TODO: check result! } - if(! -f $filename) { + if(! -f $filename || -z $filename) { + unlink($filename); $failcount++; print "- not downloaded\n"; next; |