-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add async dispose support to ZipArchive #1560
Comments
looks like duplicate of https://github.com/dotnet/corefx/issues/5681 |
|
Triage: |
This needs first to add async methods to BinaryWriter via dotnet/corefx#8382 |
Test running successfully with manandre#1 👍 [Fact]
public static async Task DiposeAsyncCallsWriteAsyncOnly()
{
MemoryStream ms = new MemoryStream();
CallTrackingStream trackingStream = new CallTrackingStream(ms);
await using (ZipArchive archive = new ZipArchive(trackingStream, ZipArchiveMode.Create))
{
archive.CreateEntry("hey");
}
Assert.Equal(0, trackingStream.TimesCalled("Write"));
Assert.NotEqual(0, trackingStream.TimesCalled("WriteAsync"));
} |
This would be beneficial for us as well! |
Is there any progress? |
We haven't made any progress recently. I am going to move it to 7.0 milestone to make sure we discuss including it in .NET 7.0 |
A workaround for this scenario is to use |
The discussion in this issue has been very helpful. I think we should implement all ZipFile and ZipArchive async APIs at the same time. For that reason, I'll close this issue in favor of the oldest and most generic issue (#1541), and will add a comment there to make sure to come back here to look at the comments here. |
In my application I am creating a ZipArchive that writes directly to the ASP.Net Core body stream, like that:
Asynchronously writing file contents to that archive works fine, but as soon as the writing is finished and the
ZipArchive
gets disposed, theZipArchive
tries to synchronously write some more data to the stream. This results in an exception, because Kestrel, by default, doesn't allow synchronous writes anymore:Enabling async disposal for this class and then doing the necessary writes asynchronously would probably resolve this issue.
The text was updated successfully, but these errors were encountered: