diff --git a/src/SharpCompress/IO/SharpCompressStream.cs b/src/SharpCompress/IO/SharpCompressStream.cs index 59a3c52d..e90a1b88 100644 --- a/src/SharpCompress/IO/SharpCompressStream.cs +++ b/src/SharpCompress/IO/SharpCompressStream.cs @@ -445,7 +445,10 @@ public class SharpCompressStream : Stream, IStreamStack if (_bufferedLength == 0) { _bufferPosition = 0; - _bufferedLength = await FillBufferMemoryAsync(_buffer.AsMemory(0, _bufferSize), cancellationToken) + _bufferedLength = await FillBufferMemoryAsync( + _buffer.AsMemory(0, _bufferSize), + cancellationToken + ) .ConfigureAwait(false); } int available = _bufferedLength - _bufferPosition; @@ -459,7 +462,10 @@ public class SharpCompressStream : Stream, IStreamStack } // If buffer exhausted, refill _bufferPosition = 0; - _bufferedLength = await FillBufferMemoryAsync(_buffer.AsMemory(0, _bufferSize), cancellationToken) + _bufferedLength = await FillBufferMemoryAsync( + _buffer.AsMemory(0, _bufferSize), + cancellationToken + ) .ConfigureAwait(false); if (_bufferedLength == 0) { diff --git a/tests/SharpCompress.Test/Zip/ZipShortReadTests.cs b/tests/SharpCompress.Test/Zip/ZipShortReadTests.cs index c3904331..1faa97a2 100644 --- a/tests/SharpCompress.Test/Zip/ZipShortReadTests.cs +++ b/tests/SharpCompress.Test/Zip/ZipShortReadTests.cs @@ -54,10 +54,16 @@ public class ZipShortReadTests : ReaderTests get => throw new NotSupportedException(); set => throw new NotSupportedException(); } + public override void Flush() => throw new NotSupportedException(); - public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException(); + + public override long Seek(long offset, SeekOrigin origin) => + throw new NotSupportedException(); + public override void SetLength(long value) => throw new NotSupportedException(); - public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException(); + + public override void Write(byte[] buffer, int offset, int count) => + throw new NotSupportedException(); } /// @@ -69,11 +75,11 @@ public class ZipShortReadTests : ReaderTests [InlineData("Zip.deflate.zip", 999, 4096)] [InlineData("Zip.deflate.zip", 100, 4096)] [InlineData("Zip.deflate.zip", 50, 512)] - [InlineData("Zip.deflate.zip", 1, 1)] // Extreme case: 1 byte at a time + [InlineData("Zip.deflate.zip", 1, 1)] // Extreme case: 1 byte at a time [InlineData("Zip.deflate.dd.zip", 1000, 4096)] [InlineData("Zip.deflate.dd.zip", 999, 4096)] [InlineData("Zip.zip64.zip", 3816, 4096)] - [InlineData("Zip.zip64.zip", 3815, 4096)] // Similar to the issue pattern + [InlineData("Zip.zip64.zip", 3815, 4096)] // Similar to the issue pattern public void Zip_Reader_Handles_Short_Reads(string zipFile, int firstReadSize, int chunkSize) { // Use an existing test ZIP file @@ -82,7 +88,7 @@ public class ZipShortReadTests : ReaderTests { return; // Skip if file doesn't exist } - + var bytes = File.ReadAllBytes(zipPath); // Baseline with MemoryStream (seekable, no short reads)