Skip to content

Instantly share code, notes, and snippets.

@retupmoca
Created March 25, 2015 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save retupmoca/5ea886e6d75f62d450b8 to your computer and use it in GitHub Desktop.
Save retupmoca/5ea886e6d75f62d450b8 to your computer and use it in GitHub Desktop.
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