Skip to content
This repository has been archived by the owner on Nov 4, 2018. It is now read-only.

Commit

Permalink
Remove recursion detection for symlinks.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jbraeuer committed Jan 31, 2012
1 parent 9c57a3b commit 22c60c1
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions S3/FileLists.py
Expand Up @@ -24,18 +24,12 @@ def _fswalk_follow_symlinks(path):
If a recursive directory link is detected, emit a warning and skip. If a recursive directory link is detected, emit a warning and skip.
''' '''
assert os.path.isdir(path) # only designed for directory argument assert os.path.isdir(path) # only designed for directory argument
walkdirs = set([path]) walkdirs = [path]
targets = set()
for dirpath, dirnames, filenames in os.walk(path): for dirpath, dirnames, filenames in os.walk(path):
for dirname in dirnames: for dirname in dirnames:
current = os.path.join(dirpath, dirname) current = os.path.join(dirpath, dirname)
target = os.path.realpath(current)
if os.path.islink(current): if os.path.islink(current):
if target in targets: walkdirs.append(current)
warning("Skipping recursively symlinked directory %s" % dirname)
else:
walkdirs.add(current)
targets.add(target)
for walkdir in walkdirs: for walkdir in walkdirs:
for value in os.walk(walkdir): for value in os.walk(walkdir):
yield value yield value
Expand Down

0 comments on commit 22c60c1

Please sign in to comment.