mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-04 05:25:00 +00:00
[PR #1132] Clean up for async creation #1567
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/adamhathcock/sharpcompress/pull/1132
State: closed
Merged: Yes
For some formats, async should be all the way. 7Zip needs fixing
This pull request introduces asynchronous detection methods for multiple archive and compression formats, allowing non-blocking checks to determine file types. It also refactors and simplifies some synchronous detection logic for improved performance and consistency. The most significant changes are grouped below:
Asynchronous Format Detection:
Added
IsArchiveAsyncor similar async methods for ACE (AceHeader.cs), ARJ (ArjHeader.cs), BZip2 (BZip2Stream.cs), LZip (LZipStream.cs), LZW (LzwStream.cs), ZStandard (ZStandardStream.cs), RAR (RarArchive.Factory.cs), SevenZip (SevenZipArchive.Factory.cs), TAR (TarArchive.Factory.cs), and XZ (XZStream.cs) formats, enabling asynchronous file type checks withCancellationTokensupport. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]Updated the ACE and ARJ factories to implement and expose these new asynchronous detection methods. [1] [2]
Synchronous Detection Refactoring & Performance:
ArrayPool<byte>.Shared) for ARC and SevenZip formats, reducing allocations and improving performance. [1] [2]API Consistency and Interface Changes:
CancellationTokenparameter from theIArchiveFactory.OpenAsyncArchivemethod and its implementations to simplify the API, as the token was not being used in actual asynchronous operations. [1] [2] [3]General Codebase Improvements:
usingdirectives forSystem.ThreadingandSystem.Threading.Taskswhere needed to support the new asynchronous methods. [1] [2] [3] [4] [5] [6] [7]These changes collectively modernize the archive/compression format detection APIs and improve their efficiency and usability.