Follow symlinks, when requested, drop recursion detection.
Michal Ludvig authored on 2012/02/23 06:29:04... | ... |
@@ -24,18 +24,12 @@ def _fswalk_follow_symlinks(path): |
24 | 24 |
If a recursive directory link is detected, emit a warning and skip. |
25 | 25 |
''' |
26 | 26 |
assert os.path.isdir(path) # only designed for directory argument |
27 |
- walkdirs = set([path]) |
|
28 |
- targets = set() |
|
27 |
+ walkdirs = [path] |
|
29 | 28 |
for dirpath, dirnames, filenames in os.walk(path): |
30 | 29 |
for dirname in dirnames: |
31 | 30 |
current = os.path.join(dirpath, dirname) |
32 |
- target = os.path.realpath(current) |
|
33 | 31 |
if os.path.islink(current): |
34 |
- if target in targets: |
|
35 |
- warning("Skipping recursively symlinked directory %s" % dirname) |
|
36 |
- else: |
|
37 |
- walkdirs.add(current) |
|
38 |
- targets.add(target) |
|
32 |
+ walkdirs.append(current) |
|
39 | 33 |
for walkdir in walkdirs: |
40 | 34 |
for value in os.walk(walkdir): |
41 | 35 |
yield value |