Closed
Description
This spawned off investigations done in dotnet/wpf#1363.
A simple reproduction in a console application can be obtained by doing:
var zp = ZipPackage.Open("test.zip", System.IO.FileMode.Create, System.IO.FileAccess.Write);
var part = zp.CreatePart(new System.Uri("/test.txt", UriKind.Relative), "");
var stream = part.GetStream(System.IO.FileMode.Create);
A NotSupportedException will arise due to this code:
The call to SetLength
fails since the underlying stream does not support this.
The flow here is:
- https://github.com/dotnet/corefx/blob/78589e4d2c98bf71cefa4dbc94cde3783b60a934/src/System.IO.Compression/src/System/IO/Compression/ZipArchiveEntry.cs#L290
ZipArchiveEntry.GetDataCompressor
creates a newDeflateStream
which is then wrapped, along with the original stream, byCheckSumAndSizeWriteStream
.
https://github.com/dotnet/corefx/blob/78589e4d2c98bf71cefa4dbc94cde3783b60a934/src/System.IO.Compression/src/System/IO/Compression/ZipArchiveEntry.cs#L600CheckSumAndSizeWriteStream
is never seekable and doesn't supportSetPosition
:
https://github.com/dotnet/corefx/blob/a10890f4ffe0fadf090c922578ba0e606ebdd16c/src/System.IO.Compression/src/System/IO/Compression/ZipCustomStreams.cs#L364
It seems that the assumption about the underlying stream is incorrect or the underlying stream should be allowing for this functionality.