commit: dc095fc06d323849a6fe47ae3391bc0356439b65 Author: Michał Górny <mgorny <AT> gentoo <DOT> org> AuthorDate: Sun Oct 20 10:22:11 2019 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Mon Oct 21 08:09:31 2019 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=dc095fc0
emirrordist: Clean dangling symlinks up Bug: https://bugs.gentoo.org/697906 Reviewed-by: Zac Medico <zmedico <AT> gentoo.org> Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> lib/portage/_emirrordist/DeletionIterator.py | 11 ++++++++--- 1 file 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
