mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Merge pull request #34239 from vutny/file-find-broken-symlinks
file.find module: fix handling of broken symlinks
This commit is contained in:
commit
f74f176bd5
@ -640,17 +640,24 @@ class Finder(object):
|
||||
for criterion in self.criteria:
|
||||
if fstat is None and criterion.requires() & _REQUIRES_STAT:
|
||||
fullpath = os.path.join(dirpath, name)
|
||||
fstat = os.stat(fullpath)
|
||||
try:
|
||||
fstat = os.stat(fullpath)
|
||||
except OSError:
|
||||
fstat = os.lstat(fullpath)
|
||||
if not criterion.match(dirpath, name, fstat):
|
||||
matches = False
|
||||
break
|
||||
|
||||
if matches:
|
||||
if fullpath is None:
|
||||
fullpath = os.path.join(dirpath, name)
|
||||
for action in self.actions:
|
||||
if (fstat is None and
|
||||
action.requires() & _REQUIRES_STAT):
|
||||
fstat = os.stat(fullpath)
|
||||
try:
|
||||
fstat = os.stat(fullpath)
|
||||
except OSError:
|
||||
fstat = os.lstat(fullpath)
|
||||
result = action.execute(fullpath, fstat, test=self.test)
|
||||
if result is not None:
|
||||
yield result
|
||||
|
Loading…
Reference in New Issue
Block a user