mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-03 21:23:38 +00:00
[PR #1018] Fix ExtractToDirectory file corruption on overwrite #1444
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/1018
State: closed
Merged: No
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.