You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-17 01:12:23 +02:00
Stupid compress issue was in the unit test - but did tighten up the code a bit.
This commit is contained in:
@ -790,8 +790,7 @@ sub copy
|
|||||||
my $strPermission = shift;
|
my $strPermission = shift;
|
||||||
|
|
||||||
# Set defaults
|
# Set defaults
|
||||||
my $bIsCompressed = false;
|
$bCompress = defined($bCompress) ? $bCompress : defined($self->{bCompress}) ? $self->{bCompress} : false;
|
||||||
$bCompress = defined($bCompress) ? $bCompress : defined($self->{bCompress}) ? $self->{bCompress} : undef;
|
|
||||||
$bIgnoreMissingSource = defined($bIgnoreMissingSource) ? $bIgnoreMissingSource : false;
|
$bIgnoreMissingSource = defined($bIgnoreMissingSource) ? $bIgnoreMissingSource : false;
|
||||||
$bPathCreate = defined($bPathCreate) ? $bPathCreate : false;
|
$bPathCreate = defined($bPathCreate) ? $bPathCreate : false;
|
||||||
|
|
||||||
@ -819,7 +818,7 @@ sub copy
|
|||||||
if (!$bSourceRemote)
|
if (!$bSourceRemote)
|
||||||
{
|
{
|
||||||
# Determine if the file is compressed
|
# Determine if the file is compressed
|
||||||
$bIsCompressed = $strSourceOp !~ "^.*\.$self->{strCompressExtension}\$";
|
# $bIsCompressed = $strSourceOp !~ "^.*\.$self->{strCompressExtension}\$";
|
||||||
|
|
||||||
open($hSourceFile, "<", $strSourceOp)
|
open($hSourceFile, "<", $strSourceOp)
|
||||||
or confess &log(ERROR, "cannot open ${strSourceOp}: " . $!);
|
or confess &log(ERROR, "cannot open ${strSourceOp}: " . $!);
|
||||||
@ -829,13 +828,13 @@ sub copy
|
|||||||
my $hDestinationFile;
|
my $hDestinationFile;
|
||||||
|
|
||||||
# Determine if the file needs compression extension
|
# Determine if the file needs compression extension
|
||||||
if ($bCompress && $strDestinationOp !~ "^.*\.$self->{strCompressExtension}\$")
|
|
||||||
{
|
|
||||||
$strDestinationOp .= "." . $self->{strCompressExtension};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$bDestinationRemote)
|
if (!$bDestinationRemote)
|
||||||
{
|
{
|
||||||
|
if ($bCompress)
|
||||||
|
{
|
||||||
|
$strDestinationOp .= "." . $self->{strCompressExtension};
|
||||||
|
}
|
||||||
|
|
||||||
open($hDestinationFile, ">", $strDestinationTmpOp)
|
open($hDestinationFile, ">", $strDestinationTmpOp)
|
||||||
or confess &log(ERROR, "cannot open ${strDestinationTmpOp}: " . $!);
|
or confess &log(ERROR, "cannot open ${strDestinationTmpOp}: " . $!);
|
||||||
}
|
}
|
||||||
@ -856,23 +855,16 @@ sub copy
|
|||||||
$hOut = $hDestinationFile;
|
$hOut = $hDestinationFile;
|
||||||
$strOperation = OP_FILE_COPY_OUT;
|
$strOperation = OP_FILE_COPY_OUT;
|
||||||
|
|
||||||
$bCompress = $bCompress ? undef : $bCompress;
|
|
||||||
|
|
||||||
if ($strSourcePathType eq PIPE_STDIN)
|
if ($strSourcePathType eq PIPE_STDIN)
|
||||||
{
|
{
|
||||||
$strRemote = 'in';
|
$strRemote = 'in';
|
||||||
$hIn = *STDIN;
|
$hIn = *STDIN;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$strRemote = 'in';
|
$strRemote = 'in';
|
||||||
$oParamHash{source_file} = ${strSourceOp};
|
$oParamHash{source_file} = ${strSourceOp};
|
||||||
|
$oParamHash{compress} = $bCompress;
|
||||||
if (defined($bCompress))
|
|
||||||
{
|
|
||||||
$oParamHash{compress} = $bCompress;
|
|
||||||
}
|
|
||||||
|
|
||||||
$hIn = $self->{oRemote}->{hOut};
|
$hIn = $self->{oRemote}->{hOut};
|
||||||
}
|
}
|
||||||
@ -892,18 +884,10 @@ sub copy
|
|||||||
{
|
{
|
||||||
$strRemote = 'out';
|
$strRemote = 'out';
|
||||||
$oParamHash{destination_file} = ${strDestinationOp};
|
$oParamHash{destination_file} = ${strDestinationOp};
|
||||||
|
$oParamHash{compress} = $bCompress;
|
||||||
$bCompress = $bCompress ? undef : $bCompress;
|
|
||||||
|
|
||||||
if (defined($bCompress))
|
|
||||||
{
|
|
||||||
$oParamHash{compress} = $bCompress;
|
|
||||||
}
|
|
||||||
|
|
||||||
$hOut = $self->{oRemote}->{hIn};
|
$hOut = $self->{oRemote}->{hIn};
|
||||||
}
|
}
|
||||||
|
|
||||||
$bCompress = true;
|
|
||||||
}
|
}
|
||||||
# Else source and destination are remote
|
# Else source and destination are remote
|
||||||
else
|
else
|
||||||
|
@ -859,6 +859,7 @@ sub BackRestFileTest
|
|||||||
{
|
{
|
||||||
system("gzip ${strSourceFile}");
|
system("gzip ${strSourceFile}");
|
||||||
$strSourceFile .= ".gz";
|
$strSourceFile .= ".gz";
|
||||||
|
$strDestinationFile .= ".gz";
|
||||||
}
|
}
|
||||||
|
|
||||||
my $strSourceHash = $oFile->hash(PATH_ABSOLUTE, $strSourceFile);
|
my $strSourceHash = $oFile->hash(PATH_ABSOLUTE, $strSourceFile);
|
||||||
@ -953,15 +954,15 @@ sub BackRestFileTest
|
|||||||
|
|
||||||
if ($bDestinationCompressed)
|
if ($bDestinationCompressed)
|
||||||
{
|
{
|
||||||
system("gzip -d ${strDestinationFileCheck}") or die "could not decompress";
|
system("gzip -d ${strDestinationFileCheck}") == 0 or die "could not decompress ${strDestinationFileCheck}";
|
||||||
}
|
}
|
||||||
|
|
||||||
# my $strDestinationHash = $oFile->hash(PATH_ABSOLUTE, $strDestinationFile);
|
my $strDestinationHash = $oFile->hash(PATH_ABSOLUTE, $strDestinationFile);
|
||||||
#
|
|
||||||
# if ($strSourceHash ne $strDestinationHash)
|
if ($strSourceHash ne $strDestinationHash)
|
||||||
# {
|
{
|
||||||
# confess "source ${strSourceHash} and destination ${strDestinationHash} file hashes do not match";
|
confess "source ${strSourceHash} and destination ${strDestinationHash} file hashes do not match";
|
||||||
# }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user