Skip to content
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 fast ExtractToDirectoryAsync extension method on IArchive #750

Merged
merged 3 commits into from
Sep 7, 2023

Conversation

FlsZen
Copy link
Contributor

@FlsZen FlsZen commented Jul 19, 2023

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.

…very fast compared to `WriteToDirectory`.
Copy link
Owner

@adamhathcock adamhathcock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Task.Run isn't for this library

@FlsZen
Copy link
Contributor Author

FlsZen commented Jul 21, 2023

I've removed the Task aspect in the implementation.

It still feels a bit odd to me since it has its own progress reporting and doesn't fire the progress events on IArchive.

@adamhathcock adamhathcock merged commit 7f80164 into adamhathcock:master Sep 7, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants