- $f->close();
- my $md5 = Digest::MD5->new;
- my $len = length($dataMD5);
- $hdr->{realSize} = $len if ( $hdr->{type} != BPC_FTYPE_FILE );
- if ( $hdr->{realSize} < 1048576
- && length($dataMD5) != $hdr->{realSize} ) {
- print(STDERR "File $hdr->{fullPath} has bad size"
- . " (expect $hdr->{realSize}, got $len)\n");
- } else {
- my $digest = $bpc->Buffer2MD5($md5, $hdr->{realSize},
- \$dataMD5);
- my $path = $bpc->MD52Path($digest, $hdr->{compress});
- my $i = -1;
-
- # print(STDERR "Looking up $hdr->{fullPath} at $path\n");
- while ( 1 ) {
- my $testPath = $path;
- $testPath .= "_$i" if ( $i >= 0 );
- last if ( !-f $testPath );
- my $inode = (stat(_))[1];
- if ( $inode == $hdr->{inode} ) {
- #
- # Found it! Just emit a tar hardlink
- #
- $testPath =~ s{\Q$TopDir\E}{..};
- $linkName = $testPath;
- last;
- }
- $i++;
+ $hdr->{realSize} = $size;
+ }
+ $f->close();
+ my $md5 = Digest::MD5->new;
+ my $len = length($dataMD5);
+ if ( $hdr->{realSize} < 1048576
+ && length($dataMD5) != $hdr->{realSize} ) {
+ print(STDERR "File $hdr->{fullPath} has bad size"
+ . " (expect $hdr->{realSize}, got $len)\n");
+ } else {
+ my $digest = $bpc->Buffer2MD5($md5, $hdr->{realSize},
+ \$dataMD5);
+ my $path = $bpc->MD52Path($digest, $hdr->{compress});
+ my $i = -1;
+
+ # print(STDERR "Looking up $hdr->{fullPath} at $path\n");
+ while ( 1 ) {
+ my $testPath = $path;
+ $testPath .= "_$i" if ( $i >= 0 );
+ last if ( !-f $testPath );
+ my $inode = (stat(_))[1];
+ if ( $inode == $hdr->{inode} ) {
+ #
+ # Found it! Just emit a tar hardlink
+ #
+ $testPath =~ s{\Q$TopDir\E}{..};
+ $linkName = $testPath;
+ last;