Browse code

Remove recursion detection for symlinks.

Recursion detection on symlinks was too restrictive. It would detect the following as recursion:

dir/
main-1234/
file1
file2
main -> main-1234

This is clearly not a recursion and a common pattern, eg when hosting package repositories.
Python's os.walk also does not do recursion detection. So lets behave like Python stdlib.

Jens Braeuer authored on 2012/01/31 18:15:08
Showing 1 changed files
... ...
@@ -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