aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2019-10-20 12:22:11 +0200
committerMichał Górny <mgorny@gentoo.org>2019-10-21 10:09:31 +0200
commitdc095fc06d323849a6fe47ae3391bc0356439b65 (patch)
tree275bd403385f40d02d3a05a4b2337e139264151d
parentemirrordist: Report all stat() errors instead of first one (diff)
downloadportage-dc095fc06d323849a6fe47ae3391bc0356439b65.tar.gz
portage-dc095fc06d323849a6fe47ae3391bc0356439b65.tar.bz2
portage-dc095fc06d323849a6fe47ae3391bc0356439b65.zip
emirrordist: Clean dangling symlinks up
Bug: https://bugs.gentoo.org/697906 Reviewed-by: Zac Medico <zmedico@gentoo.org> Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rw-r--r--lib/portage/_emirrordist/DeletionIterator.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/portage/_emirrordist/DeletionIterator.py b/lib/portage/_emirrordist/DeletionIterator.py
index dab6eaea2..5c193911a 100644
--- a/lib/portage/_emirrordist/DeletionIterator.py
+++ b/lib/portage/_emirrordist/DeletionIterator.py
@@ -27,11 +27,16 @@ class DeletionIterator(object):
# require at least one successful stat()
exceptions = []
for layout in reversed(self._config.layouts):
+ path = os.path.join(distdir, layout.get_path(filename))
try:
- st = os.stat(
- os.path.join(distdir, layout.get_path(filename)))
+ st = os.stat(path)
except OSError as e:
- exceptions.append(e)
+ # is it a dangling symlink?
+ try:
+ if os.path.islink(path):
+ os.unlink(path)
+ except OSError as e:
+ exceptions.append(e)
else:
if stat.S_ISREG(st.st_mode):
break