From 470d963f883266ceb3f28fbb674c6dd4950d381a Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Thu, 22 Oct 2015 06:25:08 -0400 Subject: sbosrcarch: show proper errors when curl fails and $maxfilemegs == 0 --- sbosrcarch | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/sbosrcarch b/sbosrcarch index c241d1c..777f2c3 100755 --- a/sbosrcarch +++ b/sbosrcarch @@ -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; -- cgit v1.2.3