From 6703e700bae22d89c8b78d89bd55869f27361836 Mon Sep 17 00:00:00 2001 From: npetrov Date: Wed, 9 Jun 2010 17:27:09 +0200 Subject: [PATCH] check for broken symlinks when using --force --- src/pypungi/__init__.py | 6 +++++- src/pypungi/util.py | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/pypungi/__init__.py b/src/pypungi/__init__.py index b04ea18e..ba1b31db 100644 --- a/src/pypungi/__init__.py +++ b/src/pypungi/__init__.py @@ -925,7 +925,11 @@ class Pungi(pypungi.PungiBase): for regex in fileres: if regex.match(filename) and not os.path.exists(os.path.join(self.topdir, filename)): self.logger.info("Linking release note file %s" % filename) - pypungi.util._link(os.path.join(dirpath, filename), os.path.join(self.topdir, filename), self.logger) + pypungi.util._link(os.path.join(dirpath, filename), + os.path.join(self.topdir, filename), + self.logger, + force=self.config.getboolean('pungi', + 'force')) self.common_files.append(filename) # Walk the tree for our dirs diff --git a/src/pypungi/util.py b/src/pypungi/util.py index 99c82cbf..0a2ea111 100644 --- a/src/pypungi/util.py +++ b/src/pypungi/util.py @@ -41,6 +41,11 @@ def _link(local, target, logger, force=False): if os.path.exists(target) and force: os.remove(target) + #check for broken links + if force and os.path.islink(target): + if not os.path.exists(os.readlink(target)): + os.remove(target) + try: os.link(local, target) except OSError, e: