From 250f97225e2b7567e01517d579b8431afc1290c9 Mon Sep 17 00:00:00 2001 From: Vladyslav Taranov Date: Sun, 15 Dec 2019 00:28:57 +0200 Subject: [PATCH 1/5] don't convert entry.Name twice when accessing updateIndex --- src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs b/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs index 003881988..013ba3c7c 100644 --- a/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs +++ b/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs @@ -1620,7 +1620,7 @@ private void AddUpdate(ZipUpdate update) { contentsEdited_ = true; - int index = FindExistingUpdate(update.Entry.Name); + int index = FindExistingUpdate(update.Entry.Name, true); if (index >= 0) { @@ -2529,13 +2529,9 @@ private void CopyEntryDataDirect(ZipUpdate update, Stream stream, bool updateCrc private int FindExistingUpdate(ZipEntry entry) { int result = -1; - string convertedName = entry.IsDirectory - ? GetTransformedDirectoryName(entry.Name) - : GetTransformedFileName(entry.Name); - - if (updateIndex_.ContainsKey(convertedName)) + if (updateIndex_.ContainsKey(entry.Name)) { - result = (int)updateIndex_[convertedName]; + result = (int)updateIndex_[entry.Name]; } /* // This is slow like the coming of the next ice age but takes less storage and may be useful @@ -2553,11 +2549,11 @@ private int FindExistingUpdate(ZipEntry entry) return result; } - private int FindExistingUpdate(string fileName) + private int FindExistingUpdate(string fileName, bool isEntityName = false) { int result = -1; - string convertedName = GetTransformedFileName(fileName); + string convertedName = !isEntityName ? GetTransformedFileName(fileName) : fileName; if (updateIndex_.ContainsKey(convertedName)) { From b6d92eba105930731a511bdebbb93710f827287f Mon Sep 17 00:00:00 2001 From: Vladyslav Taranov Date: Tue, 28 Jan 2020 09:39:53 +0200 Subject: [PATCH 2/5] Update src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Accepted suggestion Co-Authored-By: nils måsén --- src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs b/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs index 013ba3c7c..b0f9a0a33 100644 --- a/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs +++ b/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs @@ -1620,7 +1620,7 @@ private void AddUpdate(ZipUpdate update) { contentsEdited_ = true; - int index = FindExistingUpdate(update.Entry.Name, true); + int index = FindExistingUpdate(update.Entry.Name, isEntityName: true); if (index >= 0) { From 0f7759a0b3121231b497b169251538f9f9f3f0ad Mon Sep 17 00:00:00 2001 From: Vladyslav Taranov Date: Sat, 1 Feb 2020 20:24:04 +0200 Subject: [PATCH 3/5] Update src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: nils måsén --- src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs b/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs index b0f9a0a33..f9728f997 100644 --- a/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs +++ b/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs @@ -1620,7 +1620,7 @@ private void AddUpdate(ZipUpdate update) { contentsEdited_ = true; - int index = FindExistingUpdate(update.Entry.Name, isEntityName: true); + int index = FindExistingUpdate(update.Entry.Name, isEntryName: true); if (index >= 0) { From e97ec2c602f3172b4f2a866d6cf1235c75f267d8 Mon Sep 17 00:00:00 2001 From: Vladyslav Taranov Date: Sat, 1 Feb 2020 20:24:12 +0200 Subject: [PATCH 4/5] Update src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: nils måsén --- src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs b/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs index f9728f997..0a2acd8e5 100644 --- a/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs +++ b/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs @@ -2553,7 +2553,7 @@ private int FindExistingUpdate(string fileName, bool isEntityName = false) { int result = -1; - string convertedName = !isEntityName ? GetTransformedFileName(fileName) : fileName; + string convertedName = !isEntryName ? GetTransformedFileName(fileName) : fileName; if (updateIndex_.ContainsKey(convertedName)) { From 88d7c4a580c8836276baaadd5f29899d6b4d34e8 Mon Sep 17 00:00:00 2001 From: Vladyslav Taranov Date: Sat, 1 Feb 2020 20:24:30 +0200 Subject: [PATCH 5/5] Update src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: nils måsén --- src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs b/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs index 0a2acd8e5..f4f3028b5 100644 --- a/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs +++ b/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs @@ -2549,7 +2549,7 @@ private int FindExistingUpdate(ZipEntry entry) return result; } - private int FindExistingUpdate(string fileName, bool isEntityName = false) + private int FindExistingUpdate(string fileName, bool isEntryName = false) { int result = -1;