From: Brian Dolbec Date: Sun, 22 Jan 2012 17:48:36 +0000 (-0800) Subject: fix bug 398103 to properly delete broken symlinks and not abort. X-Git-Tag: gentoolkit-0.3.0.5~6 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0f152f27af3b758b904d257931c17da490468b8e;p=gentoolkit.git fix bug 398103 to properly delete broken symlinks and not abort. --- 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: