git » pygen » commit c8ff3ab

Remove symlinks before creating them.

author Alberto Bertogli
2006-07-31 03:33:21 UTC
committer Alberto Bertogli
2006-07-31 03:33:21 UTC
parent cd4ccc7d66ca55149aa44cbbe1f49feb809ebd73

Remove symlinks before creating them.
As os.symlink() won't overwrite an existing symlink, we need to remove it
manually from the destination if it exists.

The previous buggy behaviour is triggered easily by changing a symlink
destination.

pygen +2 -0

diff --git a/pygen b/pygen
index 2ebe9df..8c33f66 100644
--- a/pygen
+++ b/pygen
@@ -160,6 +160,8 @@ def autogen(src, dst):
 				if os.path.islink(fullf):
 					dlink = os.readlink(fullf)
 					print 'symlink', diff, '->', dlink
+					if os.path.exists(t):
+						os.unlink(t)
 					os.symlink(dlink, t)
 				elif os.path.isfile(fullf):
 					print 'copy', diff