/gist:5ea886e6d75f62d450b8 Secret
Created
March 25, 2015 22:27
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/lib/Git/PurePerl/Pack.pm b/lib/Git/PurePerl/Pack.pm | |
| index a69f2b9..d9d3f14 100644 | |
| --- a/lib/Git/PurePerl/Pack.pm | |
| +++ b/lib/Git/PurePerl/Pack.pm | |
| @@ -72,14 +72,17 @@ method read_compressed ($offset, $size) { | |
| my $out = Buf.new; | |
| my $decompressor = Compress::Zlib::Stream.new; | |
| - while $out.bytes < $size { | |
| + my $read = 0; | |
| + while !$decompressor.finished { | |
| my $block = $fh.read: 4096; | |
| - say $block; | |
| + $read += $block.bytes; | |
| my $data = $decompressor.inflate: $block; | |
| die $data if $data ~~ Failure; | |
| $out ~= $data; | |
| } | |
| + $fh.seek: ($offset + $read - $decompressor.bytes-left), 0; | |
| + | |
| fail "$out.bytes() is not $size" unless $out.bytes == $size; | |
| return $out; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment