Skip to content

Commit

Permalink
fix os.walk() exclusions for new upstream code
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Domsch authored and mdomsch committed Jun 19, 2012
1 parent 255d96b commit d192937
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions S3/FileLists.py
Expand Up @@ -27,13 +27,15 @@ def _fswalk_follow_symlinks(path):
assert os.path.isdir(path) # only designed for directory argument
walkdirs = [path]
for dirpath, dirnames, filenames in os.walk(path):
handle_exclude_include_walk(dirpath, dirnames, [])
for dirname in dirnames:
current = os.path.join(dirpath, dirname)
if os.path.islink(current):
walkdirs.append(current)
for walkdir in walkdirs:
for value in os.walk(walkdir):
yield value
for dirpath, dirnames, filenames in os.walk(walkdir):
handle_exclude_include_walk(dirpath, dirnames, [])
yield (dirpath, dirnames, filenames)

def _fswalk(path, follow_symlinks):
'''
Expand All @@ -44,8 +46,10 @@ def _fswalk(path, follow_symlinks):
follow_symlinks (bool) indicates whether to descend into symbolically linked directories
'''
if follow_symlinks:
return _fswalk_follow_symlinks(path)
return os.walk(path)
yield _fswalk_follow_symlinks(path)
for dirpath, dirnames, filenames in os.walk(path):
handle_exclude_include_walk(dirpath, dirnames, filenames)
yield (dirpath, dirnames, filenames)

def filter_exclude_include(src_list):
info(u"Applying --exclude/--include")
Expand Down Expand Up @@ -147,7 +151,6 @@ def _get_filelist_local(local_uri):
single_file = True
loc_list = SortedDict(ignore_case = False)
for root, dirs, files in filelist:
handle_exclude_include_walk(root, dirs, files)
rel_root = root.replace(local_path, local_base, 1)
for f in files:
full_name = os.path.join(root, f)
Expand Down

0 comments on commit d192937

Please sign in to comment.