Rewind buffer fix for directory extract.

This commit is contained in:
Nanook
2025-08-01 21:47:09 +01:00
parent 35aee6e066
commit 76de7d54c7
6 changed files with 37 additions and 4 deletions

View File

@@ -330,7 +330,7 @@ public class ZipArchive : AbstractWritableArchive<ZipArchiveEntry, ZipVolume>
protected override IReader CreateReaderForSolidExtraction()
{
var stream = Volumes.Single().Stream;
stream.Position = 0;
((IStreamStack)stream).StackSeek(0);
return ZipReader.Open(stream, ReaderOptions, Entries);
}
}

View File

@@ -50,7 +50,6 @@ internal sealed class StreamingZipFilePart : ZipFilePart
if (_decompressionStream is DeflateStream deflateStream)
{
((IStreamStack)rewindableStream).StackSeek(0);
//rewindableStream.Rewind(deflateStream.InputBuffer);
}
Skipped = true;

View File

@@ -22,7 +22,18 @@ internal class StreamingZipHeaderFactory : ZipHeaderFactory
{
if (stream is not SharpCompressStream) //ensure the stream is already a SharpCompressStream. So the buffer/size will already be set
{
throw new ArgumentException("Stream must be a SharpCompressStream", nameof(stream));
if (stream is SourceStream src) //the original code wrapped this with RewindableStream. Wrap with SharpCOmpressStream as we can get the boffer size
{
stream = new SharpCompressStream(
stream,
src.ReaderOptions.LeaveStreamOpen,
bufferSize: src.ReaderOptions.BufferSize
);
}
else
{
throw new ArgumentException("Stream must be a SharpCompressStream", nameof(stream));
}
}
SharpCompressStream rewindableStream = (SharpCompressStream)stream;