[PR #1004] Async XZ #1425

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

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

State: closed
Merged: Yes


related to: https://github.com/adamhathcock/sharpcompress/issues/992
This pull request adds asynchronous support to the XZ decompression library, enabling non-blocking operations for reading and processing XZ archives. The main changes include introducing async versions of core parsing and validation methods, updating stream and binary reader utilities to support async reads, and ensuring that all major XZ format components (header, block, index, footer) can be processed asynchronously.

Async API additions for XZ format components:

  • Added async factory and processing methods to XZHeader, XZBlock, XZIndex, XZIndexRecord, and XZFooter, allowing these classes to be read and validated asynchronously from streams. [1] [2] [3] [4] [5]

Async stream and binary reader utilities:

  • Introduced async extension methods in BinaryUtils.cs and MultiByteIntegers.cs for reading little-endian integers and multi-byte XZ integers from streams and BinaryReader. These include cancellation token support. [1] [2]

Async parsing logic in XZBlock and XZIndex:

  • Refactored internal logic in XZBlock and XZIndex to provide async versions of header loading, padding skipping, CRC checking, and marker verification, ensuring all parsing steps can be performed asynchronously. [1] [2] [3] [4] [5] [6] [7] [8]

Async CRC and validation routines:

  • Added async CRC verification methods and updated validation steps in XZHeader, XZFooter, and XZIndex to use async reads and CRC calculations, supporting cancellation. [1] [2] [3]

General infrastructure updates:

  • Added necessary using statements for System.Threading and System.Threading.Tasks to all relevant files to support async functionality. [1] [2] [3] [4] [5] [6] [7] [8]
**Original Pull Request:** https://github.com/adamhathcock/sharpcompress/pull/1004 **State:** closed **Merged:** Yes --- related to: https://github.com/adamhathcock/sharpcompress/issues/992 This pull request adds asynchronous support to the XZ decompression library, enabling non-blocking operations for reading and processing XZ archives. The main changes include introducing async versions of core parsing and validation methods, updating stream and binary reader utilities to support async reads, and ensuring that all major XZ format components (header, block, index, footer) can be processed asynchronously. **Async API additions for XZ format components:** * Added async factory and processing methods to `XZHeader`, `XZBlock`, `XZIndex`, `XZIndexRecord`, and `XZFooter`, allowing these classes to be read and validated asynchronously from streams. [[1]](diffhunk://#diff-15f5707406f62593d17aed80733c3d431c3bbe021f484c01a1c88b24cb600e42R28-R49) [[2]](diffhunk://#diff-ad9279f946db1ad81165540a7926d1789169b96d9ea478ba03fec9a248844394R77-R119) [[3]](diffhunk://#diff-f4ac1e08cc5bb70cc442f08291bc3316ddc83cf4fa8160da3daab8432bc0ee35R44-R57) [[4]](diffhunk://#diff-1651d2170bf88dfb11cac77f43f2a6c5e19c6b8b8015c5f82876732f257c8d3fR23-R34) [[5]](diffhunk://#diff-60cd5672108f5df94b5c9ea9678db7ed0c577bcd221b9e7e126275fa57f1a14dR32-R41) **Async stream and binary reader utilities:** * Introduced async extension methods in `BinaryUtils.cs` and `MultiByteIntegers.cs` for reading little-endian integers and multi-byte XZ integers from streams and `BinaryReader`. These include cancellation token support. [[1]](diffhunk://#diff-62adfc69c67a76a6dbb2b99ba861c0da791ba8999a48405df74f2b0dc59c0f63R35-R56) [[2]](diffhunk://#diff-55120b3d2b88cc2630b664fc3d5821c86921454f8678360a7e9389be62dff65aR44-R114) **Async parsing logic in XZBlock and XZIndex:** * Refactored internal logic in `XZBlock` and `XZIndex` to provide async versions of header loading, padding skipping, CRC checking, and marker verification, ensuring all parsing steps can be performed asynchronously. [[1]](diffhunk://#diff-ad9279f946db1ad81165540a7926d1789169b96d9ea478ba03fec9a248844394R135-R151) [[2]](diffhunk://#diff-ad9279f946db1ad81165540a7926d1789169b96d9ea478ba03fec9a248844394R161-R169) [[3]](diffhunk://#diff-ad9279f946db1ad81165540a7926d1789169b96d9ea478ba03fec9a248844394R197-R211) [[4]](diffhunk://#diff-ad9279f946db1ad81165540a7926d1789169b96d9ea478ba03fec9a248844394R221-R231) [[5]](diffhunk://#diff-ad9279f946db1ad81165540a7926d1789169b96d9ea478ba03fec9a248844394R252-R275) [[6]](diffhunk://#diff-f4ac1e08cc5bb70cc442f08291bc3316ddc83cf4fa8160da3daab8432bc0ee35R74-R93) [[7]](diffhunk://#diff-f4ac1e08cc5bb70cc442f08291bc3316ddc83cf4fa8160da3daab8432bc0ee35R103-R111) [[8]](diffhunk://#diff-f4ac1e08cc5bb70cc442f08291bc3316ddc83cf4fa8160da3daab8432bc0ee35R125-R152) **Async CRC and validation routines:** * Added async CRC verification methods and updated validation steps in `XZHeader`, `XZFooter`, and `XZIndex` to use async reads and CRC calculations, supporting cancellation. [[1]](diffhunk://#diff-15f5707406f62593d17aed80733c3d431c3bbe021f484c01a1c88b24cb600e42R68-R87) [[2]](diffhunk://#diff-60cd5672108f5df94b5c9ea9678db7ed0c577bcd221b9e7e126275fa57f1a14dR64-R88) [[3]](diffhunk://#diff-f4ac1e08cc5bb70cc442f08291bc3316ddc83cf4fa8160da3daab8432bc0ee35R125-R152) **General infrastructure updates:** * Added necessary `using` statements for `System.Threading` and `System.Threading.Tasks` to all relevant files to support async functionality. [[1]](diffhunk://#diff-62adfc69c67a76a6dbb2b99ba861c0da791ba8999a48405df74f2b0dc59c0f63R4-R5) [[2]](diffhunk://#diff-55120b3d2b88cc2630b664fc3d5821c86921454f8678360a7e9389be62dff65aR3-R4) [[3]](diffhunk://#diff-ad9279f946db1ad81165540a7926d1789169b96d9ea478ba03fec9a248844394R7-R8) [[4]](diffhunk://#diff-60cd5672108f5df94b5c9ea9678db7ed0c577bcd221b9e7e126275fa57f1a14dR4-R5) [[5]](diffhunk://#diff-15f5707406f62593d17aed80733c3d431c3bbe021f484c01a1c88b24cb600e42R4-R5) [[6]](diffhunk://#diff-f4ac1e08cc5bb70cc442f08291bc3316ddc83cf4fa8160da3daab8432bc0ee35R6-R7) [[7]](diffhunk://#diff-1651d2170bf88dfb11cac77f43f2a6c5e19c6b8b8015c5f82876732f257c8d3fR3-R4) [[8]](diffhunk://#diff-ac3f8a33f27e97f618b5177fa107cdb4e26e43031510a9896223d8f67a83418eR5-R6)
claunia added the pull-request label 2026-01-29 22:20:30 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1425