diff options
author | Olivier Thauvin <nanardon@mandriva.org> | 2005-01-03 16:38:40 +0000 |
---|---|---|
committer | Olivier Thauvin <nanardon@mandriva.org> | 2005-01-03 16:38:40 +0000 |
commit | d4f28b53147fa97f0f4feddf861804f6d9a8afed (patch) | |
tree | 826c53c61aa3266af16f16d6e297838c10b611b6 | |
parent | 068bd6155c75fdbc0b88846a9717fa52624dce7a (diff) | |
download | rpmtools-d4f28b53147fa97f0f4feddf861804f6d9a8afed.tar rpmtools-d4f28b53147fa97f0f4feddf861804f6d9a8afed.tar.gz rpmtools-d4f28b53147fa97f0f4feddf861804f6d9a8afed.tar.bz2 rpmtools-d4f28b53147fa97f0f4feddf861804f6d9a8afed.tar.xz rpmtools-d4f28b53147fa97f0f4feddf861804f6d9a8afed.zip |
- fix data read detection when using cache
-rw-r--r-- | Packdrakeng.pm | 5 | ||||
-rw-r--r-- | 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); } |