-
Notifications
You must be signed in to change notification settings - Fork 5.3k
throw exception when creating an entry name that already exists in ZipArchive #60973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
1340883
8ee2ada
959d736
cf7068f
2887dbe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -388,6 +388,11 @@ private ZipArchiveEntry DoCreateEntry(string entryName, CompressionLevel? compre | |
| if (_mode == ZipArchiveMode.Read) | ||
| throw new NotSupportedException(SR.CreateInReadMode); | ||
|
|
||
| if (_entriesDictionary.ContainsKey(entryName)) | ||
| { | ||
| throw new InvalidOperationException(string.Format(SR.EntryNameAlreadyExists, entryName)); | ||
| } | ||
|
Comment on lines
+391
to
+394
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm working on getting various MAUI workloads running on .NET 7. One of our tests hit an issue due to this change. An MSBuild task inside a NuGet package has the following call: Previously the code was creating a new entry then removing the old one afterward. (Code is old, it may indeed be incorrect) Is the new exception intentional? Is it something that needs to be on a "breaking changes" list somewhere?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I filed an issue; it seems I can reproduce in a smaller example: #68734 |
||
|
|
||
| ThrowIfDisposed(); | ||
|
|
||
|
|
||
|
|
@@ -421,12 +426,7 @@ internal void AcquireArchiveStream(ZipArchiveEntry entry) | |
| private void AddEntry(ZipArchiveEntry entry) | ||
| { | ||
| _entries.Add(entry); | ||
|
|
||
| string entryName = entry.FullName; | ||
| if (!_entriesDictionary.ContainsKey(entryName)) | ||
| { | ||
| _entriesDictionary.Add(entryName, entry); | ||
| } | ||
| _entriesDictionary.Add(entry.FullName, entry); | ||
carlossanlop marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| [Conditional("DEBUG")] | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.