From 0f152f27af3b758b904d257931c17da490468b8e Mon Sep 17 00:00:00 2001 From: Brian Dolbec Date: Sun, 22 Jan 2012 09:48:36 -0800 Subject: [PATCH] fix bug 398103 to properly delete broken symlinks and not abort. --- pym/gentoolkit/eclean/clean.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/pym/gentoolkit/eclean/clean.py b/pym/gentoolkit/eclean/clean.py index b2cc562..fd59976 100644 --- a/pym/gentoolkit/eclean/clean.py +++ b/pym/gentoolkit/eclean/clean.py @@ -125,10 +125,22 @@ class CleanUp(object): try: statinfo = os.stat(file_) except EnvironmentError as er: - print( pp.error( - "Could not get stat info for:" + file_), file=sys.stderr) - print( pp.error( - "Error: %s" %str(er)), file=sys.stderr) + if not os.path.exists(os.readlink(file_)): + try: + os.remove(file_) + print( pp.error( + "Removed broken symbolic link " + file_), file=sys.stderr) + break + except EnvironmentError as er: + print( pp.error( + "Error deleting broken symbolic link " + file_), file=sys.stderr) + print( pp.error("Error: %s" %str(er)), file=sys.stderr) + break + else: + print( pp.error( + "Could not get stat info for:" + file_), file=sys.stderr) + print( pp.error( + "Error: %s" %str(er)), file=sys.stderr) if self.controller(statinfo.st_size, key, file_, file_type): # ... try to delete it. try: -- 2.26.2