diff options
author | Gary Oberbrunner <garyo@oberbrunner.com> | 2011-02-18 03:01:29 (GMT) |
---|---|---|
committer | Gary Oberbrunner <garyo@oberbrunner.com> | 2011-02-18 03:01:29 (GMT) |
commit | 83001323a2f70372d0d41398dc22b9e21fb5e860 (patch) | |
tree | 3d950c212ee2169473b5626c12afcf500f6c970a /src/engine/SCons/Defaults.py | |
parent | 18097a7686a70d499f8fc83001bf517b06a61864 (diff) | |
download | SCons-83001323a2f70372d0d41398dc22b9e21fb5e860.zip SCons-83001323a2f70372d0d41398dc22b9e21fb5e860.tar.gz SCons-83001323a2f70372d0d41398dc22b9e21fb5e860.tar.bz2 |
Fix #2708 by making Delete able to delete broken symlinks and dir symlinks.
Thanks to David Garcia Garzon for the patch.
Diffstat (limited to 'src/engine/SCons/Defaults.py')
-rw-r--r-- | src/engine/SCons/Defaults.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index bbc2571..a99bcc7 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -199,14 +199,15 @@ def delete_func(dest, must_exist=0): dest = [dest] for entry in dest: entry = str(entry) - if not must_exist and not os.path.exists(entry): + # os.path.exists returns False with broken links that exist + entry_exists = os.path.exists(entry) or os.path.islink(entry) + if not entry_exists and not must_exist: continue - if not os.path.exists(entry) or os.path.isfile(entry): - os.unlink(entry) - continue - else: + # os.path.isdir returns True when entry is a link to a dir + if os.path.isdir(entry) and not os.path.islink(entry): shutil.rmtree(entry, 1) continue + os.unlink(entry) def delete_strfunc(dest, must_exist=0): return 'Delete(%s)' % get_paths_str(dest) |