diff --git a/salt/utils/find.py b/salt/utils/find.py index ea2d8c9d3b..2c0bc43466 100644 --- a/salt/utils/find.py +++ b/salt/utils/find.py @@ -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