diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2012-07-26T21·11-0400 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2012-07-26T21·11-0400 |
commit | 7892ad15ab4b6db0eee619a1fdd14fed129db252 (patch) | |
tree | 89887267ad0dd07a81fc975b69830a550e974cb8 /scripts | |
parent | dbce685e91c513341dedf8c1a916ef4c62f5650a (diff) |
download-from-binary-cache: Support file://
The file:// URI schema requires checking for errors in a more general way. Also, don't cache file:// lookups.
Diffstat (limited to '')
-rw-r--r-- | scripts/download-from-binary-cache.pl.in | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/scripts/download-from-binary-cache.pl.in b/scripts/download-from-binary-cache.pl.in index 5fb0419f181a..10d0db9adbcf 100644 --- a/scripts/download-from-binary-cache.pl.in +++ b/scripts/download-from-binary-cache.pl.in @@ -45,6 +45,7 @@ sub addRequest { $curl->setopt(CURLOPT_CAINFO, $caBundle) if defined $caBundle; $curl->setopt(CURLOPT_USERAGENT, "Nix/$Nix::Config::version"); $curl->setopt(CURLOPT_NOBODY, 1) if $head; + $curl->setopt(CURLOPT_FAILONERROR, 1); if ($activeRequests >= $maxParallelRequests) { $scheduled{$curlId} = 1; @@ -73,7 +74,7 @@ sub processRequests { my $request = $requests{$id} or die; my $handle = $request->{handle}; $request->{result} = $result; - $request->{httpStatus} = $handle->getinfo(CURLINFO_HTTP_CODE); + $request->{httpStatus} = $handle->getinfo(CURLINFO_RESPONSE_CODE); print STDERR "$request->{type} on $request->{url} [$request->{result}, $request->{httpStatus}]\n" if $debug; @@ -179,12 +180,13 @@ sub processNARInfo { my $cacheId = getCacheId($binaryCacheUrl); - if ($request->{result} != 0 || $request->{httpStatus} != 200) { - if ($request->{httpStatus} != 404) { + if ($request->{result} != 0) { + if ($request->{result} != 37 && $request->{httpStatus} != 404) { print STDERR "could not download ‘$request->{url}’ (" . ($request->{result} != 0 ? "Curl error $request->{result}" : "HTTP status $request->{httpStatus}") . ")\n"; } else { - $insertNARExistence->execute($cacheId, basename($storePath), 0, time()); + $insertNARExistence->execute($cacheId, basename($storePath), 0, time()) + unless $request->{url} =~ /^file:/; } return undef; } @@ -219,7 +221,8 @@ sub processNARInfo { # Cache the result. $insertNAR->execute( $cacheId, basename($storePath), $url, $compression, $fileHash, $fileSize, - $narHash, $narSize, join(" ", @refs), $deriver, $system, time()); + $narHash, $narSize, join(" ", @refs), $deriver, $system, time()) + unless $request->{url} =~ /^file:/; return { url => $url @@ -378,16 +381,18 @@ sub printSubstitutablePaths { processRequests; foreach my $request (values %requests) { - if ($request->{result} != 0 || $request->{httpStatus} != 200) { - if ($request->{httpStatus} != 404) { + if ($request->{result} != 0) { + if ($request->{result} != 37 && $request->{httpStatus} != 404) { print STDERR "could not check ‘$request->{url}’ (" . ($request->{result} != 0 ? "Curl error $request->{result}" : "HTTP status $request->{httpStatus}") . ")\n"; } else { - $insertNARExistence->execute($cacheId, basename($request->{storePath}), 0, time()); + $insertNARExistence->execute($cacheId, basename($request->{storePath}), 0, time()) + unless $request->{url} =~ /^file:/; } push @left2, $request->{storePath}; } else { - $insertNARExistence->execute($cacheId, basename($request->{storePath}), 1, time()); + $insertNARExistence->execute($cacheId, basename($request->{storePath}), 1, time()) + unless $request->{url} =~ /^file:/; print "$request->{storePath}\n"; } } |