Don't use __opts__.get() for hash_type

First of all, the opts will never not have this key, as it has a default
value in salt/config/__init__.py. Second, the default hash type changed
to sha256 anyway in 2016.11, so we shouldn't be referring to a specific
hash type when it'll no longer be accurate after a merge-forward.
This commit is contained in:
Erik Johnson 2017-04-05 21:35:56 -05:00
parent 0918311330
commit 8c61f333ae

View file

@ -4456,7 +4456,7 @@ def manage_file(name,
if not sfn:
return _error(
ret, 'Source file \'{0}\' not found'.format(source))
htype = source_sum.get('hash_type', __opts__.get('hash_type', 'md5'))
htype = source_sum.get('hash_type', __opts__['hash_type'])
# Recalculate source sum now that file has been cached
source_sum = {
'hash_type': htype,
@ -4472,12 +4472,12 @@ def manage_file(name,
# Only test the checksums on files with managed contents
if source and not (not follow_symlinks and os.path.islink(real_name)):
name_sum = get_hash(real_name, source_sum.get('hash_type', __opts__.get('hash_type', 'md5')))
name_sum = get_hash(real_name, source_sum.get('hash_type', __opts__['hash_type']))
else:
name_sum = None
# Check if file needs to be replaced
if source and (name_sum is None or source_sum.get('hsum', __opts__.get('hash_type', 'md5')) != name_sum):
if source and (name_sum is None or source_sum.get('hsum', __opts__['hash_type']) != name_sum):
if not sfn:
sfn = __salt__['cp.cache_file'](source, saltenv)
if not sfn: