archive - fix removal failures for nested files with tar archives (#2923)

* Initial commit

* Adding changelog fragment
This commit is contained in:
Ajpantuso 2021-07-02 15:30:40 -04:00 committed by GitHub
commit ffe505a798
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 8 deletions

View file

@ -399,13 +399,14 @@ class Archive(object):
def remove_targets(self):
for path in self.successes:
try:
if os.path.isdir(path):
shutil.rmtree(path)
else:
os.remove(path)
except OSError:
self.errors.append(_to_native(path))
if os.path.exists(path):
try:
if os.path.isdir(path):
shutil.rmtree(path)
else:
os.remove(path)
except OSError:
self.errors.append(_to_native(path))
for path in self.paths:
try:
if os.path.isdir(path):