Fix GZip write async#1319
Closed
adamhathcock wants to merge 1 commit into
Closed
Conversation
Owner
Author
|
Wrong branch |
Merged
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes async save/create behavior for writable GZip archives by enabling writable entries to provide an async-capable entry stream (avoiding the NotImplementedException reported in #1316), and adds an async round-trip test to validate the behavior.
Changes:
- Made
GZipArchiveEntry.OpenEntryStreamAsyncvirtual so writable entry types can override async stream-opening behavior. - Implemented
OpenEntryStreamAsyncoverride inGZipWritableArchiveEntry(supports cancellation and returnsValueTask<Stream>). - Added a new async test that creates a
.gzarchive, saves it asynchronously, re-opens it asynchronously, and verifies extracted content integrity.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/SharpCompress.Test/GZip/GZipArchiveAsyncTests.cs | Adds an async create/save/open/extract test for GZip archives. |
| src/SharpCompress/Archives/GZip/GZipWritableArchiveEntry.cs | Overrides OpenEntryStreamAsync for writable entries to avoid Parts access and support async save paths. |
| src/SharpCompress/Archives/GZip/GZipArchiveEntry.cs | Makes OpenEntryStreamAsync virtual to allow writable implementations to override. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+207
to
+208
| await using var archive2 = await GZipArchive.OpenAsyncArchive( | ||
| new AsyncOnlyStream(File.OpenRead(filePath)) |
| using SharpCompress.Archives.Tar; | ||
| using SharpCompress.Common; | ||
| using SharpCompress.Compressors.Deflate; | ||
| using SharpCompress.Readers; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #1316
This pull request adds asynchronous support for opening entry streams in GZip archive entries and introduces new tests to ensure correct async behavior. The main focus is on enabling async operations for GZip writable archive entries and verifying them with comprehensive test coverage.
Async support for GZip archive entries:
OpenEntryStreamAsyncvirtual inGZipArchiveEntryto allow overriding for async stream opening.OpenEntryStreamAsyncinGZipWritableArchiveEntrythat supports cancellation and returns aValueTask<Stream>.System.ThreadingandSystem.Threading.Tasksnamespaces for async/cancellation support inGZipWritableArchiveEntry.Test improvements:
GZip_Create_New_Asyncto verify creating, saving, and extracting GZip archives asynchronously, ensuring file integrity.