Bug Fix in permission setter (#10584)

* fix permission setter

Fix a typo in islink test when applied to files.

* os.walk explicitly set not to follow links

The algorithm strongly rely on not following links.
This commit is contained in:
abernede 2019-02-13 20:18:36 +01:00 committed by Greg Becker
parent a76c50d1ee
commit 89727ba4e7

View File

@ -15,7 +15,8 @@ def forall_files(path, fn, args, dir_args=None):
"""Apply function to all files in directory, with file as first arg. """Apply function to all files in directory, with file as first arg.
Does not apply to the root dir. Does not apply to links""" Does not apply to the root dir. Does not apply to links"""
for root, dirs, files in os.walk(path): # os.walk explicitly set not to follow links
for root, dirs, files in os.walk(path, followlinks=False):
for d in dirs: for d in dirs:
if not os.path.islink(os.path.join(root, d)): if not os.path.islink(os.path.join(root, d)):
if dir_args: if dir_args:
@ -23,7 +24,7 @@ def forall_files(path, fn, args, dir_args=None):
else: else:
fn(os.path.join(root, d), *args) fn(os.path.join(root, d), *args)
for f in files: for f in files:
if not os.path.islink(os.path.join(root, d)): if not os.path.islink(os.path.join(root, f)):
fn(os.path.join(root, f), *args) fn(os.path.join(root, f), *args)