-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revisit Seekability of writable zip streams #1364
Comments
This is not an issue as PackagePart.GetStream will return seekable streams when the stream is writeable. This is the reason that the workaround is to open your package as writeable. |
I see, though #1363 still produced a non seekable stream for writing, so I worry that it can also happen in GetSeekableStream and pass through undetected, silently dropping data. This worry might be unfounded since we don't yet know the root cause of #1363 but it might be worth adding checks to ensure that GetSeekableStream never creates a MemoryStream wrapper when opening something as writable. Maybe throw an exception if this unexpected case ever happens, so that instead of silently dropping the data there is something to diagnose. Your choice, if you think your tests cover this well enough to detect it if that ever regresses it might not be necessary. |
I am entirely sympathetic to the more cautious approach. I'm going to root cause #1363 and figure out where that sits in relation to the changes. I think your suggestion on testing write vs. seekability is a reasonable one and I'll leave this open as a conduit for potentially changing it. |
@weltkante Be aware that I am not assigning this just yet, I'll let our normal triage process pick it up since by then I'll have more info. |
In PR #1311 (issue #585) two writable streams (Certificate.cs and XmlDigitalSignatureProcessor.cs) get wrapped in a memory stream by calling the new method
GetSeekableStream(FileMode.Create, FileAccess.Write)
. It is unclear from the PR source how the written data will be propagated to the actual zip stream. Since this was noticed after the PR merged I'm opening a separate issue to revisit the handling of writable streams.I'd also argue that the current implementation of GetSeekableStream should not have had
FileMode
andFileAccess
paramters, since the only case which is handled correctly is the open/read combination.I'd suggest either providing a dedicated stream wrapper class and keeping FileMode/FileAccess, or remove FileMode/FileAccess and provide a separate code path for callers who want to write data.
Related: issue #1363 apparently still has call sites which do not get wrapped
The text was updated successfully, but these errors were encountered: