mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Raise CommandExecutionError when file doesn't exist
Re-add CommandExecutionError in win_file Add CommandExecutionError in file Add Try/Except block in file when getting file metadata
This commit is contained in:
parent
4602f499a2
commit
e3c3845f73
2 changed files with 11 additions and 4 deletions
|
@ -3368,7 +3368,7 @@ def stats(path, hash_type=None, follow_symlinks=True):
|
|||
pstat = os.lstat(path)
|
||||
except OSError:
|
||||
# Not a broken symlink, just a nonexistent path
|
||||
return ret
|
||||
raise CommandExecutionError('Path not found: {0}'.format(path))
|
||||
else:
|
||||
if follow_symlinks:
|
||||
pstat = os.stat(path)
|
||||
|
@ -4498,11 +4498,18 @@ def check_file_meta(
|
|||
'''
|
||||
changes = {}
|
||||
if not source_sum:
|
||||
source_sum = {}
|
||||
lstats = stats(name, hash_type=source_sum.get('hash_type', None), follow_symlinks=False)
|
||||
source_sum = dict()
|
||||
|
||||
try:
|
||||
lstats = stats(name, hash_type=source_sum.get('hash_type', None),
|
||||
follow_symlinks=False)
|
||||
except CommandExecutionError:
|
||||
lstats = {}
|
||||
|
||||
if not lstats:
|
||||
changes['newfile'] = name
|
||||
return changes
|
||||
|
||||
if 'hsum' in source_sum:
|
||||
if source_sum['hsum'] != lstats['sum']:
|
||||
if not sfn and source:
|
||||
|
|
|
@ -821,7 +821,7 @@ def stats(path, hash_type='sha256', follow_symlinks=True):
|
|||
# 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):
|
||||
return {}
|
||||
raise CommandExecutionError('Path not found: {0}'.format(path))
|
||||
|
||||
if follow_symlinks and sys.getwindowsversion().major >= 6:
|
||||
path = _resolve_symlink(path)
|
||||
|
|
Loading…
Add table
Reference in a new issue