Skip to content

Commit

Permalink
[backend] fix compress_entry call in create_layer_data
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed Apr 24, 2023
1 parent 7a9825e commit 2282ff3
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/backend/BSContar.pm
Original file line number Diff line number Diff line change
Expand Up @@ -318,21 +318,20 @@ sub normalize_container {
}
my $newcomp = 'gzip';
if (!$comp || $comp ne $newcomp || $recompress) {
my $outfile;
if ($tmpdir) {
$outfile = "$tmpdir/.compress_entry_${cnt}.$$";
$cnt++;
unlink($outfile);
}
if ($comp) {
print "recompressing $layer_ent->{'name'}... ";
} else {
print "compressing $layer_ent->{'name'}... ";
}
if ($tmpdir) {
my $outfile = "$tmpdir/.compress_entry_${cnt}.$$";
unlink($outfile);
$layer_ent = compress_entry($layer_ent, $comp, $newcomp, $outfile);
unlink($outfile);
$cnt++;
} else {
$layer_ent = compress_entry($layer_ent, $comp, $newcomp);
}
$layer_ent = compress_entry($layer_ent, $comp, $newcomp, $outfile);
print "done.\n";
unlink($outfile) if $outfile;
}
my $blobid = blobid_entry($layer_ent);
$newblobs{$blobid} ||= { %$layer_ent, 'name' => $blobid };
Expand Down Expand Up @@ -433,8 +432,12 @@ sub create_layer_data {
$comp ||= detect_entry_compression($layer_ent);
$newcomp ||= $oci && $comp eq 'zstd' ? 'zstd' : 'gzip';
if ($comp ne $newcomp) {
print "compressing $layer_ent->{'name'}... ";
$layer_ent = compress_layer_ent($layer_ent, $comp, $newcomp);
if ($comp) {
print "recompressing $layer_ent->{'name'}... ";
} else {
print "compressing $layer_ent->{'name'}... ";
}
$layer_ent = compress_entry($layer_ent, $comp, $newcomp);
print "done.\n";
undef $lcomp;
}
Expand Down

0 comments on commit 2282ff3

Please sign in to comment.