Skip to content

Fix exception from deleting a directory ZipEntry in a ZipFile#295

Merged
piksel merged 1 commit intoicsharpcode:masterfrom
benleedom:master
Jan 3, 2019
Merged

Fix exception from deleting a directory ZipEntry in a ZipFile#295
piksel merged 1 commit intoicsharpcode:masterfrom
benleedom:master

Conversation

@benleedom
Copy link
Copy Markdown
Contributor

ZipFile.FindExistingUpdate(ZipEntry) would always return -1 for directory ZipEntrys due to using GetTransformedFileName on all ZipEntrys. As a result, ZipFile.Delete(ZipEntry) would always throw an exception when passed a directory ZipEntry. The fix is to call GetTransformedDirectoryName for directory ZipEntrys.

I updated the test AddAndDeleteEntries in ZipFileHandling.cs to add and delete a directory; this test failed without the change to ZipFile.FindExistingUpdate.

I believe issue #290 is related.

I certify that I own, and have sufficient rights to contribute, all source code and related material intended to be compiled or integrated with the source code for the SharpZipLib open source product (the "Contribution"). My Contribution is licensed under the MIT License.

@piksel
Copy link
Copy Markdown
Member

piksel commented Jan 3, 2019

So, the consequence of this bug is that the entry name ends with a slash when created with ZipFile.AddDirectory, but not when it's searched for by ZipFile.Delete (which of course means it will not find it).

Test looks good. I'll try to release a bugfix update with this commit soon.

@piksel piksel merged commit 0269465 into icsharpcode:master Jan 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants