From d4f28b53147fa97f0f4feddf861804f6d9a8afed Mon Sep 17 00:00:00 2001 From: Olivier Thauvin Date: Mon, 3 Jan 2005 16:38:40 +0000 Subject: - fix data read detection when using cache --- Packdrakeng.pm | 5 ++++- Packdrakeng/zlib.pm | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Packdrakeng.pm b/Packdrakeng.pm index e822dad..86e3942 100644 --- a/Packdrakeng.pm +++ b/Packdrakeng.pm @@ -410,7 +410,7 @@ sub extern_uncompress { while ($byteswritten < $fileinfo->{size}) { my $data = $pack->{ustream_data}{buf}; $pack->{ustream_data}{buf} = undef; - my $length = 0; + my $length; if (!defined($data)) { $length = sysread($pack->{ustream_data}{handle}, $data, $pack->{bufsize}) or do { $pack->{log}("Unexpected end of stream $pack->{ustream_data}{tempname}"); @@ -419,6 +419,8 @@ sub extern_uncompress { $pack->{ustream_data} = undef; return -1; }; + } else { + $length = length($data); } if ($pack->{ustream_data}{read} < $fileinfo->{off} && $pack->{ustream_data}{read} + $length > $fileinfo->{off}) { @@ -431,6 +433,7 @@ sub extern_uncompress { if ($byteswritten + length($data) > $fileinfo->{size}) { $bw = $fileinfo->{size} - $byteswritten; $pack->{ustream_data}{buf} = substr($data, $bw); # keeping track of unwritten uncompressed data + $pack->{ustream_data}{read} -= length($pack->{ustream_data}{buf}); } else { $bw = length($data); } diff --git a/Packdrakeng/zlib.pm b/Packdrakeng/zlib.pm index 72fe9e2..2478649 100644 --- a/Packdrakeng/zlib.pm +++ b/Packdrakeng/zlib.pm @@ -153,8 +153,8 @@ sub gzip_uncompress { warn("Unable to uncompress data"); return -1; }; - $l = length($out) or next; } + $l = length($out) or next; if ($pack->{ustream_data}{read} < $fileinfo->{off} && $pack->{ustream_data}{read} + $l > $fileinfo->{off}) { $out = substr($out, $fileinfo->{off} - $pack->{ustream_data}{read}); } @@ -165,6 +165,7 @@ sub gzip_uncompress { if ($byteswritten + length($out) > $fileinfo->{size}) { $bw = $fileinfo->{size} - $byteswritten; $pack->{ustream_data}{buf} = substr($out, $bw); # keeping track of unwritten uncompressed data + $pack->{ustream_data}{read} -= length($pack->{ustream_data}{buf}); } else { $bw = length($out); } -- cgit v1.2.1