fixing ZipPackagePart.GetStreamCore crashes with NotSupportedException (dotnet/corefx...
authorSteven Kirbach <steven.kirbach@gmail.com>
Thu, 15 Aug 2019 15:25:45 +0000 (08:25 -0700)
committerGitHub <noreply@github.com>
Thu, 15 Aug 2019 15:25:45 +0000 (08:25 -0700)
commitbb5e9114e8bda019e2241568edc497c643c793ce
treebbfb4d126172e2d738bf208cec4e14c32ef8e126
parent4bd1f048d424a3642e37f00bd44e92c16b3959ab
fixing ZipPackagePart.GetStreamCore crashes with NotSupportedException (dotnet/corefx#40319)

* fixing ZipPackagePart.GetStreamCore crashes with NotSupportedException

ZipArchiveEntry only ever supports opening once when the backing archive is in Create mode,  and the backing stream is non-seekable, so we shouldn't call SetLength in that case. You could still open an archive in Update mode then call part.GetStream(FileMode.Create), in which case we'll want this call to SetLength, so we only avoid this call when the backing Archive is in Create mode.

* updating test to explicitly test the Update path for ZipPackage

* skip UAP since we don't have access to the file system to create the .zip

* undo accidental change to existing test

* removing unnecessary variable

Commit migrated from https://github.com/dotnet/corefx/commit/8ac53e0c022b7881f659e0838a25e91f2ec5c8c0
src/libraries/System.IO.Packaging/src/System/IO/Packaging/ZipPackagePart.cs
src/libraries/System.IO.Packaging/tests/Tests.cs