Question

Is there a way prevent tarfile.extractall (API) from overwriting existing files? By "prevent" I mean ideally raising an exception when an overwrite is about to happen. The current behavior is to silently overwrite the files.

Was it helpful?

Solution

You could check result of tarfile.getnames against the existing files and raise your error.

OTHER TIPS

Have you tried setting tarfile.errorlevel to 2? That will cause non-fatal errors to be raised. I'm assuming an overwrite falls in that category.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top