Skip to content

fix: Change LeaveStreamOpen default from true to false - #1293

Merged
adamhathcock merged 9 commits into
adamhathcock:masterfrom
puk06:fix/leave-stream-open-default
Apr 21, 2026
Merged

adamhathcock merged 9 commits into
adamhathcock:masterfrom
puk06:fix/leave-stream-open-default

Conversation

@puk06

@puk06 puk06 commented Apr 20, 2026 •

Copy link
Copy Markdown
Contributor

As of v0.21, the library is documented to close wrapped streams by default. However, the ReaderOptions.LeaveStreamOpen property defaulted to true, which contradicted the documented behavior and caused file locks when deleting archives after extraction.

Changes:

  • Set LeaveStreamOpen = false as the default (consistent with v0.21 design)
  • Updated ReaderOptions.cs with comprehensive documentation explaining:
    • File-based vs caller-provided stream handling
    • When to use LeaveStreamOpen = true
    • Usage examples for both scenarios
  • Updated AGENTS.md Stream Handling Rules section with:
    • Clear explanation of default disposal behavior
    • Overload differences (file-based vs stream-based)
    • Guidance on using ForExternalStream preset

This ensures the implementation matches the documented behavior and prevents unexpected file locking issues during archive deletion.

Fixes: File deletion failures after archive extraction


Please note that while this change aligns with the documented specification, it is a breaking change that may affect existing code.
The removal of the explicit LeaveStreamOpen=false override in ZipArchive was motivated by the fact that false is now the default. However, since other Archive types originally relied on the default value of true, existing code that does not explicitly specify ReaderOptions may behave differently than before.
Breaking changes of this nature should be documented somewhere. That said, since I'm not familiar enough with where exactly the documentation should be updated, I've opted not to include those changes in this pull request.

As of v0.21, the library is documented to close wrapped streams by default.
However, the ReaderOptions.LeaveStreamOpen property defaulted to true, which
contradicted the documented behavior and caused file locks when deleting
archives after extraction.

Changes:
- Set LeaveStreamOpen = false as the default (consistent with v0.21 design)
- Updated ReaderOptions.cs with comprehensive documentation explaining:
  * File-based vs caller-provided stream handling
  * When to use LeaveStreamOpen = true
  * Usage examples for both scenarios
- Updated AGENTS.md Stream Handling Rules section with:
  * Clear explanation of default disposal behavior
  * Overload differences (file-based vs stream-based)
  * Guidance on using ForExternalStream preset

This ensures the implementation matches the documented behavior and prevents
unexpected file locking issues during archive deletion.

Fixes: File deletion failures after archive extraction
Copilot AI review requested due to automatic review settings April 20, 2026 13:37

This comment was marked as outdated.

@puk06
puk06 marked this pull request as draft April 20, 2026 13:52
@adamhathcock
adamhathcock marked this pull request as ready for review April 20, 2026 13:59
@adamhathcock
adamhathcock marked this pull request as draft April 20, 2026 13:59
@puk06

puk06 commented Apr 21, 2026

Copy link
Copy Markdown
Contributor Author

Please note that while this change aligns with the documented specification, it is a breaking change that may affect existing code.
The removal of the explicit LeaveStreamOpen=false override in ZipArchive was motivated by the fact that false is now the default. However, since other Archive types originally relied on the default value of true, existing code that does not explicitly specify ReaderOptions may behave differently than before.
Breaking changes of this nature should be documented somewhere. That said, since I'm not familiar enough with where exactly the documentation should be updated, I've opted not to include those changes in this pull request.

@puk06
puk06 marked this pull request as ready for review April 21, 2026 00:26
Copilot AI review requested due to automatic review settings April 21, 2026 00:26

This comment was marked as outdated.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 21, 2026 00:32

This comment was marked as outdated.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 21, 2026 00:40

This comment was marked as outdated.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 21, 2026 00:48

This comment was marked as outdated.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 21, 2026 01:09

This comment was marked as outdated.

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.

3 participants