mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-03 21:23:38 +00:00
[PR #1018] [CLOSED] Fix ExtractToDirectory file corruption on overwrite #1439
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?
📋 Pull Request Information
Original PR: https://github.com/adamhathcock/sharpcompress/pull/1018
Author: @Copilot
Created: 11/14/2025
Status: ❌ Closed
Base:
master← Head:copilot/fix-ziparchive-extraction-issue📝 Commits (2)
0ecbe02Initial plandd242cbFix ExtractToDirectory to properly truncate existing files📊 Changes
2 files changed (+23 additions, -1 deletions)
View changed files
📝
src/SharpCompress/Archives/IArchiveExtensions.cs(+1 -1)📝
tests/SharpCompress.Test/Zip/ZipArchiveTests.cs(+22 -0)📄 Description
ExtractToDirectoryusesFile.OpenWrite()which doesn't truncate existing files. When extracting over a directory with existing files, if the new content is shorter, old data remains at the end causing corruption.Changes
File.OpenWrite(path)toFile.Create(path)to ensure files are truncated before writingZip_Deflate_ArchiveExtractToDirectory_Overwritethat verifies correct behavior when extracting twice to the same directoryExample
Note: The reported issue of "no files extracted" could not be reproduced. The fix addresses the file truncation bug which could manifest as apparent extraction failures in applications that validate extracted content.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.