Check for errors when compressing NARs
Otherwise, an error (like disk full) will cause a truncated NAR file to be uploaded to the binary cache.
This commit is contained in:
parent
e4b04c877f
commit
97b39b07dc
|
@ -59,7 +59,9 @@ my $bucket = $s3->bucket($bucketName) or die;
|
||||||
|
|
||||||
|
|
||||||
# Fetch the manifest.
|
# Fetch the manifest.
|
||||||
system("$curl '$srcChannelURL/MANIFEST' > $dstChannelPath/MANIFEST") == 0 or die;
|
unless (-e "$dstChannelPath/MANIFEST") {
|
||||||
|
system("$curl '$srcChannelURL/MANIFEST' > $dstChannelPath/MANIFEST") == 0 or die;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (defined $nixexprsURL) {
|
if (defined $nixexprsURL) {
|
||||||
|
@ -144,6 +146,7 @@ sub mirrorStorePath {
|
||||||
# Verify that $storePath hasn't been corrupted and compress it at the same time.
|
# Verify that $storePath hasn't been corrupted and compress it at the same time.
|
||||||
$ext = "xz";
|
$ext = "xz";
|
||||||
my $narHash = `bash -c 'exec 4>&1; nix-store --dump $storePath | tee >(nix-hash --type sha256 --base32 --flat /dev/stdin >&4) | xz -7 > $dstFileTmp'`;
|
my $narHash = `bash -c 'exec 4>&1; nix-store --dump $storePath | tee >(nix-hash --type sha256 --base32 --flat /dev/stdin >&4) | xz -7 > $dstFileTmp'`;
|
||||||
|
die "unable to compress $storePath to $dstFileTmp\n" if $? != 0;
|
||||||
chomp $narHash;
|
chomp $narHash;
|
||||||
die "hash mismatch in `$storePath'" if "sha256:$narHash" ne $nar->{narHash};
|
die "hash mismatch in `$storePath'" if "sha256:$narHash" ne $nar->{narHash};
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue