Return empty or unmodified dict on file not found

Fixes issue with file.managed with test=True when the directory
structure for the file is not there and makedirs=True
This commit is contained in:
twangboy 2017-09-06 14:39:26 -06:00
parent 4643a112e7
commit 6a4e77e4b9
No known key found for this signature in database
GPG key ID: 93FF3BDEB278C9EB

View file

@ -818,8 +818,10 @@ def stats(path, hash_type='sha256', follow_symlinks=True):
salt '*' file.stats /etc/passwd
'''
# This is to mirror the behavior of file.py. `check_file_meta` expects an
# empty dictionary when the file does not exist
if not os.path.exists(path):
raise CommandExecutionError('Path not found: {0}'.format(path))
return {}
if follow_symlinks and sys.getwindowsversion().major >= 6:
path = _resolve_symlink(path)
@ -1556,6 +1558,13 @@ def check_perms(path,
# Specify advanced attributes with a list
salt '*' file.check_perms C:\\Temp\\ Administrators "{'jsnuffy': {'perms': ['read_attributes', 'read_ea'], 'applies_to': 'files_only'}}"
'''
# This is to work with the state module.
if not os.path.exists(path):
if ret:
return ret
else:
raise CommandExecutionError('The directory does not exist.')
path = os.path.expanduser(path)
if not ret: