[PR #750] [MERGED] Add fast ExtractToDirectoryAsync extension method on IArchive #1203

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

📋 Pull Request Information

Original PR: https://github.com/adamhathcock/sharpcompress/pull/750
Author: @FlsZen
Created: 7/19/2023
Status: Merged
Merged: 9/7/2023
Merged by: @adamhathcock

Base: masterHead: master


📝 Commits (3)

  • c7c143f Add ExtractToDirectoryAsync extension method on IArchive that is very fast compared to WriteToDirectory.
  • 4e23b84 Remove Task aspect
  • ec01225 It looks like build format wants this on one line

📊 Changes

1 file changed (+55 additions, -0 deletions)

View changed files

📝 src/SharpCompress/Archives/IArchiveExtensions.cs (+55 -0)

📄 Description

As mentioned in #728 (and I believe some other issues), the IArchive.WriteToDirectory(...) extension method can be very slow for .7z files. This extension utilized IArchive.ExtractAllEntries() and IReader so is fast for .7z files.

Being async has nothing to do with the performance, rather, it's because I use this extension method from an async method and need it to perform the long-running work asynchronously. Ideally IArchive.ExtractAllEntries() and IReader.WriteEntryTo(Stream) would be async as well and then the whole Task.Run wouldn't be needed and then it would make more sense to be async.

It currently doesn't support ExtractionOptions or reporting progress through IArchive's events (although it does report progress through a callback). But, it works great as-is for my use case, which I suspect is pretty common, and I wanted to share.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/adamhathcock/sharpcompress/pull/750 **Author:** [@FlsZen](https://github.com/FlsZen) **Created:** 7/19/2023 **Status:** ✅ Merged **Merged:** 9/7/2023 **Merged by:** [@adamhathcock](https://github.com/adamhathcock) **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (3) - [`c7c143f`](https://github.com/adamhathcock/sharpcompress/commit/c7c143fed975cb0618c2a675e086ed1b634da37a) Add `ExtractToDirectoryAsync` extension method on `IArchive` that is very fast compared to `WriteToDirectory`. - [`4e23b84`](https://github.com/adamhathcock/sharpcompress/commit/4e23b84999ffbdcf48fb8e8487023ea9929962c9) Remove Task aspect - [`ec01225`](https://github.com/adamhathcock/sharpcompress/commit/ec01225225889c871c8a5d64596a2a3465e22f89) It looks like build format wants this on one line ### 📊 Changes **1 file changed** (+55 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/SharpCompress/Archives/IArchiveExtensions.cs` (+55 -0) </details> ### 📄 Description As mentioned in #728 (and I believe some other issues), the `IArchive.WriteToDirectory(...)` extension method can be very slow for `.7z` files. This extension utilized `IArchive.ExtractAllEntries()` and `IReader` so is fast for .7z files. Being async has nothing to do with the performance, rather, it's because I use this extension method from an async method and need it to perform the long-running work asynchronously. Ideally `IArchive.ExtractAllEntries()` and `IReader.WriteEntryTo(Stream)` would be async as well and then the whole Task.Run wouldn't be needed and then it would make more sense to be async. It currently doesn't support `ExtractionOptions` or reporting progress through `IArchive`'s events (although it does report progress through a callback). But, it works great as-is for my use case, which I suspect is pretty common, and I wanted to share. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 22:19:28 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1203