When extracting a file using ZipFile / TarFile, add an option to overwrite existing files.
Some ZipFiles have duplicates files in them (syslinks), and allowing to overwrite them will allow to extract them, instead of writing a fix around it.
I’ve sat down and wrote a proposal for the feature, which I used in the Issue I opened on GitHub
I would be glad if there was an option to overwrite old files when extracting new files with the same name at the same location.
It can be a new parameter, which will be defaulted to False, which if true, will check if there is a file / directory with the same path. If it doesn’t have, it will delete the existing file /directory before writing the new ones.
I’m writing a program which is extracting a archive to a location the user want me to extract it.
When extracting with CLI tools, if there is a file that will have the same path as existing file, I will get a prompt which will ask me if I want to replace the old file with the new one.
But I’m Python I have to check if there is a file with the same path of the file I’m going to extract, otherwise I will get a file exists exception.
Why not make it built in?
Also, by adding it as an optional Parameter, we won’t break backwards compatibility.