mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #25067 from The-Loeki/patch-1
Fix for maxdepth=0 in find
This commit is contained in:
commit
15f2a4077c
1 changed files with 22 additions and 22 deletions
|
@ -637,29 +637,29 @@ class Finder(object):
|
|||
depth = dirpath[len(path) + len(os.path.sep):].count(os.path.sep)
|
||||
if depth == self.maxdepth:
|
||||
dirs[:] = []
|
||||
else:
|
||||
if depth >= self.mindepth:
|
||||
for name in dirs + files:
|
||||
fstat = None
|
||||
matches = True
|
||||
fullpath = None
|
||||
for criterion in self.criteria:
|
||||
if fstat is None and criterion.requires() & _REQUIRES_STAT:
|
||||
fullpath = os.path.join(dirpath, name)
|
||||
fstat = os.stat(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
|
||||
|
||||
if depth >= self.mindepth:
|
||||
for name in dirs + files:
|
||||
fstat = None
|
||||
matches = True
|
||||
fullpath = None
|
||||
for criterion in self.criteria:
|
||||
if fstat is None and criterion.requires() & _REQUIRES_STAT:
|
||||
fullpath = os.path.join(dirpath, name)
|
||||
fstat = os.stat(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)
|
||||
result = action.execute(fullpath, fstat, test=self.test)
|
||||
if result is not None:
|
||||
yield result
|
||||
fstat = os.stat(fullpath)
|
||||
result = action.execute(fullpath, fstat, test=self.test)
|
||||
if result is not None:
|
||||
yield result
|
||||
|
||||
|
||||
def find(path, options):
|
||||
|
|
Loading…
Add table
Reference in a new issue