Cache normalized destination path during Zip extraction - #131792
Open
alinpahontu2912 with Copilot wants to merge 2 commits into
Open
Cache normalized destination path during Zip extraction#131792alinpahontu2912 with Copilot wants to merge 2 commits into
alinpahontu2912 with Copilot wants to merge 2 commits into
Conversation
Co-authored-by: alinpahontu2912 <56953855+alinpahontu2912@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
alinpahontu2912
August 4, 2026 10:18
View session
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors ZIP extraction to compute and reuse a normalized destination directory root once per ExtractToDirectory / ExtractToDirectoryAsync invocation, rather than recomputing it for every entry extracted.
Changes:
- Added
ZipFileExtensions.GetDestinationDirectoryFullPath(string)to compute the destination root once (create + ensure trailing directory separator). - Updated per-entry extraction helpers to take the pre-normalized destination root instead of the raw destination directory name.
- Updated all extraction entry points (sync/async, ZipArchive- and ZipFile-based) to compute the destination root once prior to iterating entries.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.IO.Compression.ZipFile/src/System/IO/Compression/ZipFileExtensions.ZipArchiveEntry.Extract.cs | Introduces GetDestinationDirectoryFullPath and updates per-entry extraction helpers to use a cached normalized root. |
| src/libraries/System.IO.Compression.ZipFile/src/System/IO/Compression/ZipFileExtensions.ZipArchiveEntry.Extract.Async.cs | Updates async entry extraction to use the pre-normalized destination root. |
| src/libraries/System.IO.Compression.ZipFile/src/System/IO/Compression/ZipFileExtensions.ZipArchive.Extract.cs | Computes the destination root once per extraction and passes it through the entry loop. |
| src/libraries/System.IO.Compression.ZipFile/src/System/IO/Compression/ZipFileExtensions.ZipArchive.Extract.Async.cs | Same as above for async ZipArchive extraction APIs. |
| src/libraries/System.IO.Compression.ZipFile/src/System/IO/Compression/ZipFile.Extract.cs | Computes the destination root once per extraction and reuses it while extracting ZipFile entries. |
| src/libraries/System.IO.Compression.ZipFile/src/System/IO/Compression/ZipFile.Extract.Async.cs | Same as above for async ZipFile extraction APIs. |
| ArgumentNullException.ThrowIfNull(source); | ||
| ArgumentNullException.ThrowIfNull(destinationDirectoryName); | ||
|
|
||
| string destinationDirectoryFullPath = GetDestinationDirectoryFullPath(destinationDirectoryName); |
Contributor
|
Tagging subscribers to this area: @karelz, @dotnet/area-system-io-compression |
alinpahontu2912
marked this pull request as ready for review
August 4, 2026 11:08
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
… regression test Co-authored-by: alinpahontu2912 <56953855+alinpahontu2912@users.noreply.github.com>
This was referenced Aug 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ExtractRelativeToDirectoryCheckIfFilerecomputed the destination root'sDirectory.CreateDirectoryandPath.GetFullPathnormalization on every entry, even though the root is constant for the entireExtractToDirectory/ExtractToDirectoryAsynccall.Changes
ZipFileExtensions.GetDestinationDirectoryFullPath(string), computing the normalized root (create + trailing separator) once.ExtractRelativeToDirectoryCheckIfFile,ExtractRelativeToDirectory, andExtractRelativeToDirectoryAsyncnow take the pre-normalized root instead of the raw destination directory name.ZipFile.Extract(.Async).cs,ZipFileExtensions.ZipArchive.Extract(.Async).cs) to compute the root once before iterating entries, reusing it across the loop.