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

* Initial commit

* Adding changelog fragment

(cherry picked from commit ffe505a798)

Co-authored-by: Ajpantuso <ajpantuso@gmail.com>
This commit is contained in:
patchback[bot]
2021-07-02 21:43:25 +02:00
committed by GitHub
parent 55ce4af134
commit 257b268746
3 changed files with 45 additions and 8 deletions

View File

@@ -380,13 +380,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):