pgbackrest.git / summary / log / commit / refs

commit    0b3b743f5a6030bedf92f736bc6cb6021f2ced48
Author:   David Steele <github@thelabyrinth.net>
Date:     Sun Jun 15 23:18:26 2014 +0000

    Stupid compress issue was in the unit test - but did tighten up the code a bit.


lib/BackRest/File.pm | 34 +++++++++------------------------- test/lib/BackRestTest/FileTest.pm | 15 ++++++++------- 2 files changed, 17 insertions(+), 32 deletions(-) diff --git a/lib/BackRest/File.pm b/lib/BackRest/File.pm index 42e6cfe75..902a4a878 100644 --- a/lib/BackRest/File.pm +++ b/lib/BackRest/File.pm @@ -790,8 +790,7 @@ sub copy my $strPermission = shift; # Set defaults - my $bIsCompressed = false; - $bCompress = defined($bCompress) ? $bCompress : defined($self->{bCompress}) ? $self->{bCompress} : undef; + $bCompress = defined($bCompress) ? $bCompress : defined($self->{bCompress}) ? $self->{bCompress} : false; $bIgnoreMissingSource = defined($bIgnoreMissingSource) ? $bIgnoreMissingSource : false; $bPathCreate = defined($bPathCreate) ? $bPathCreate : false; @@ -819,7 +818,7 @@ sub copy if (!$bSourceRemote) { # Determine if the file is compressed - $bIsCompressed = $strSourceOp !~ "^.*\.$self->{strCompressExtension}\$"; +# $bIsCompressed = $strSourceOp !~ "^.*\.$self->{strCompressExtension}\$"; open($hSourceFile, "<", $strSourceOp) or confess &log(ERROR, "cannot open ${strSourceOp}: " . $!); @@ -829,13 +828,13 @@ sub copy my $hDestinationFile; # Determine if the file needs compression extension - if ($bCompress && $strDestinationOp !~ "^.*\.$self->{strCompressExtension}\$") - { - $strDestinationOp .= "." . $self->{strCompressExtension}; - } - if (!$bDestinationRemote) { + if ($bCompress) + { + $strDestinationOp .= "." . $self->{strCompressExtension}; + } + open($hDestinationFile, ">", $strDestinationTmpOp) or confess &log(ERROR, "cannot open ${strDestinationTmpOp}: " . $!); } @@ -856,23 +855,16 @@ sub copy $hOut = $hDestinationFile; $strOperation = OP_FILE_COPY_OUT; - $bCompress = $bCompress ? undef : $bCompress; - if ($strSourcePathType eq PIPE_STDIN) { $strRemote = 'in'; $hIn = *STDIN; - } else { $strRemote = 'in'; $oParamHash{source_file} = ${strSourceOp}; - - if (defined($bCompress)) - { - $oParamHash{compress} = $bCompress; - } + $oParamHash{compress} = $bCompress; $hIn = $self->{oRemote}->{hOut}; } @@ -892,18 +884,10 @@ sub copy { $strRemote = 'out'; $oParamHash{destination_file} = ${strDestinationOp}; - - $bCompress = $bCompress ? undef : $bCompress; - - if (defined($bCompress)) - { - $oParamHash{compress} = $bCompress; - } + $oParamHash{compress} = $bCompress; $hOut = $self->{oRemote}->{hIn}; } - - $bCompress = true; } # Else source and destination are remote else diff --git a/test/lib/BackRestTest/FileTest.pm b/test/lib/BackRestTest/FileTest.pm index 7cf9f2225..1afc570e3 100755 --- a/test/lib/BackRestTest/FileTest.pm +++ b/test/lib/BackRestTest/FileTest.pm @@ -859,6 +859,7 @@ sub BackRestFileTest { system("gzip ${strSourceFile}"); $strSourceFile .= ".gz"; + $strDestinationFile .= ".gz"; } my $strSourceHash = $oFile->hash(PATH_ABSOLUTE, $strSourceFile); @@ -953,15 +954,15 @@ sub BackRestFileTest 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); - # - # if ($strSourceHash ne $strDestinationHash) - # { - # confess "source ${strSourceHash} and destination ${strDestinationHash} file hashes do not match"; - # } + my $strDestinationHash = $oFile->hash(PATH_ABSOLUTE, $strDestinationFile); + + if ($strSourceHash ne $strDestinationHash) + { + confess "source ${strSourceHash} and destination ${strDestinationHash} file hashes do not match"; + } } } } [parent: d162ce203d6c]