X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FXfer%2FRsyncDigest.pm;h=2790346502f01e7598f784aaa4a2489f3196a233;hp=b2d5f5000f2e7e2d58d8a03957b2ff268918076f;hb=e3a3959dcdb461886ed2d5fa4bcd3e345e750e7a;hpb=ee969a9445a5439cf94a516c7d882e12b1bdf945 diff --git a/lib/BackupPC/Xfer/RsyncDigest.pm b/lib/BackupPC/Xfer/RsyncDigest.pm index b2d5f50..2790346 100644 --- a/lib/BackupPC/Xfer/RsyncDigest.pm +++ b/lib/BackupPC/Xfer/RsyncDigest.pm @@ -105,7 +105,7 @@ sub fileDigestIsCached binmode($fh); return -2 if ( sysread($fh, $data, 1) != 1 ); close($fh); - return $data eq chr(0xd6) ? 1 : 0; + return $data eq chr(0xd7) ? 1 : 0; } # @@ -121,7 +121,8 @@ sub fileDigestIsCached # sub digestAdd { - my($class, $file, $blockSize, $checksumSeed, $verify) = @_; + my($class, $file, $blockSize, $checksumSeed, $verify, + $protocol_version) = @_; my $retValue = 0; # @@ -140,6 +141,8 @@ sub digestAdd return -101 if ( !$RsyncLibOK ); my $digest = File::RsyncP::Digest->new; + $digest->protocol($protocol_version) + if ( defined($protocol_version) ); $digest->add(pack("V", $checksumSeed)) if ( $checksumSeed ); return -102 if ( !defined(my $fh = BackupPC::FileZIO->open($file, 0, 1)) ); @@ -171,7 +174,7 @@ sub digestAdd sysopen(my $fh2, $file, O_RDWR) || return -103; binmode($fh2); return -104 if ( sysread($fh2, $data, 1) != 1 ); - if ( $data ne chr(0x78) && $data ne chr(0xd6) ) { + if ( $data ne chr(0x78) && $data ne chr(0xd6) && $data ne chr(0xd7) ) { &$Log(sprintf("digestAdd: $file has unexpected first char 0x%x", ord($data))); return -105; @@ -183,7 +186,7 @@ sub digestAdd # # Verify the cached checksums # - return -107 if ( $data ne chr(0xd6) ); + return -107 if ( $data ne chr(0xd7) ); return -108 if ( sysread($fh2, $data3, length($data2) + 1) < 0 ); if ( $data2 eq $data3 ) { return 1; @@ -220,7 +223,7 @@ sub digestAdd } } return -113 if ( !defined(sysseek($fh2, 0, 0)) ); - return -114 if ( syswrite($fh2, chr(0xd6)) != 1 ); + return -114 if ( syswrite($fh2, chr(0xd7)) != 1 ); close($fh2); return $retValue; } @@ -254,9 +257,11 @@ sub digestStart name => $fileName, needMD4 => $needMD4, digest => File::RsyncP::Digest->new, + protocol_version => $protocol_version, }, $class; - $dg->{digest}->protocol($protocol_version); + $dg->{digest}->protocol($dg->{protocol_version}) + if ( defined($dg->{protocol_version}) ); if ( $fileSize > 0 && $compress && $doCache >= 0 ) { open(my $fh, "<", $fileName) || return -2; @@ -282,7 +287,7 @@ sub digestStart $blockSize || BackupPC::Xfer::RsyncDigest->blockSize( $fileSize, $defBlkSize), - $checksumSeed); + $checksumSeed, $dg->{protocol_version}); if ( $ret < 0 ) { &$Log("digestAdd($fileName) failed ($ret)"); } @@ -293,7 +298,7 @@ sub digestStart binmode($fh); return -5 if ( read($fh, $data, 1) != 1 ); } - if ( $ret >= 0 && $data eq chr(0xd6) ) { + if ( $ret >= 0 && $data eq chr(0xd7) ) { # # Looks like this file has cached checksums # Read the last 48 bytes: that's 2 file MD4s (32 bytes) @@ -343,6 +348,8 @@ sub digestStart return -9 if ( !defined($dg->{fh}) ); if ( $needMD4) { $dg->{csumDigest} = File::RsyncP::Digest->new; + $dg->{csumDigest}->protocol($dg->{protocol_version}) + if ( defined($dg->{protocol_version}) ); $dg->{csumDigest}->add(pack("V", $dg->{checksumSeed})); } } @@ -387,7 +394,13 @@ sub digestEnd if ( $dg->{cached} ) { close($dg->{fh}); - return $dg->{md4DigestOld} if ( $dg->{needMD4} ); + if ( $dg->{needMD4} ) { + if ( $dg->{protocol_version} <= 26 ) { + return $dg->{md4DigestOld}; + } else { + return $dg->{md4Digest}; + } + } } else { # # make sure we read the entire file for the file MD4 digest