Open lstreepy opened 4 years ago
It seems you have indeed stumbled upon a bug -- I created a PR with unit test to demonstrate this, based on your code.
This library is optimized towards packing and unpacking use-cases and ZIP->ZIP transformations are not very well supported. I guess a workaround for now would be to unpack the archive to file system and then pack it again. During unpacking and packing, you can supply your NameMapper
to perform renames.
I also briefly looked at fixing the bug myself but it seems that it needs a bigger design change in the internals of zt-zip. I hope @toomasr or @reinra will have a chance to look at this at some point.
I am trying to rename entries in a zip file. Best would be to do it in place, but I can't even get it to work when copying to a new zip file. Here is the code for my attempt:
However, when I run this, I get this exception:
Investigating the code in Zips, it appears that the name mapper causes it to try to find the renamed entry in the SOURCE zip instead of changing the name in the destination zip. That seems counter-intuitive at best, and may be a bug.
I'm sure that I have missed something, but I can't find a way to rename an entry in a zip file. I see that you 3rd functional requirement was to support renaming entries, but I can't figure it out with the documentation I can find.
I apologize if this is my lack of knowledge on how to use your library (which has been awesome for all my other needs).
Thanks, Larry.