mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +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
1 changed files with 9 additions and 2 deletions
|
@ -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…
Add table
Reference in a new issue