[PR #980] adds more async tests and overloads to make things writable and async #1398

Open
opened 2026-01-29 22:20:22 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/adamhathcock/sharpcompress/pull/980

State: closed
Merged: Yes


This pull request adds asynchronous support for saving and extracting archives in the SharpCompress library. It introduces new async methods for writing archive entries and saving entire archives, enabling non-blocking I/O operations and cancellation support. The changes span core archive types (Zip, Tar, GZip), extension methods, and add comprehensive async extraction capabilities.

Async archive saving and extraction:

  • Added SaveToAsync methods to IWritableArchive, AbstractWritableArchive, and their extension classes, allowing archives to be saved asynchronously to streams and files with cancellation support. [1] [2] [3]
  • Implemented SaveToAsync overrides for ZipArchive, TarArchive, and GZipArchive to asynchronously write archive entries using their respective writers. [1] [2] [3]

Async entry extraction:

  • Added WriteToAsync, WriteToDirectoryAsync, and WriteToFileAsync extension methods to IArchiveEntryExtensions, enabling asynchronous extraction of archive entries to streams, directories, or files. [1] [2] [3]

Async writer support:

  • Extended TarWriter with WriteAsync methods for writing entries asynchronously, supporting progress, cancellation, and stream size validation.

Testing improvements:

  • Added async test helpers in ArchiveTests.cs to verify asynchronous archive extraction and ensure correctness of the new async APIs.

These changes modernize the library for better scalability and responsiveness in applications that use SharpCompress for large or remote archives.

**Original Pull Request:** https://github.com/adamhathcock/sharpcompress/pull/980 **State:** closed **Merged:** Yes --- This pull request adds asynchronous support for saving and extracting archives in the SharpCompress library. It introduces new async methods for writing archive entries and saving entire archives, enabling non-blocking I/O operations and cancellation support. The changes span core archive types (Zip, Tar, GZip), extension methods, and add comprehensive async extraction capabilities. **Async archive saving and extraction:** * Added `SaveToAsync` methods to `IWritableArchive`, `AbstractWritableArchive`, and their extension classes, allowing archives to be saved asynchronously to streams and files with cancellation support. [[1]](diffhunk://#diff-24d9933c6237700ff8ddf5307ee56793bc52e832fb97cf59fb093fbe49440d9fR23-R28) [[2]](diffhunk://#diff-d9ed0f511148da76d233d734091d18177d526bcb026ed5463061cde0c6d00c7cR146-R157) [[3]](diffhunk://#diff-4ab4fbb9acbd843bb76dcbb65a3e6d752eca4e6b630faa7ff533c5bb13048518R47-R64) * Implemented `SaveToAsync` overrides for `ZipArchive`, `TarArchive`, and `GZipArchive` to asynchronously write archive entries using their respective writers. [[1]](diffhunk://#diff-fdeace22df51f39be3461b03ffceb3ae6b63a006fa2f3428c3a4df6728354dc8R322-R339) [[2]](diffhunk://#diff-7f2eb9160ad6da95a3247f13cfb74c5556ae75ba12daaf9eeeab0edd8cd965d0R247-R270) [[3]](diffhunk://#diff-e39c32ff250a34b1b406d0cf4189b9f994b87ac4705576f32040829b4cf97870R211-R232) **Async entry extraction:** * Added `WriteToAsync`, `WriteToDirectoryAsync`, and `WriteToFileAsync` extension methods to `IArchiveEntryExtensions`, enabling asynchronous extraction of archive entries to streams, directories, or files. [[1]](diffhunk://#diff-61084e55d70b594ef97e944a0bc645b95f63a1854f75f17a038ab224850cfa0cR35-R62) [[2]](diffhunk://#diff-61084e55d70b594ef97e944a0bc645b95f63a1854f75f17a038ab224850cfa0cR78-R94) [[3]](diffhunk://#diff-61084e55d70b594ef97e944a0bc645b95f63a1854f75f17a038ab224850cfa0cR113-R132) **Async writer support:** * Extended `TarWriter` with `WriteAsync` methods for writing entries asynchronously, supporting progress, cancellation, and stream size validation. **Testing improvements:** * Added async test helpers in `ArchiveTests.cs` to verify asynchronous archive extraction and ensure correctness of the new async APIs. These changes modernize the library for better scalability and responsiveness in applications that use SharpCompress for large or remote archives.
claunia added the pull-request label 2026-01-29 22:20:22 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1398