From 64ae3f996ea15443b247fac555cb1cc65f9063a8 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Mon, 30 Nov 2015 16:44:06 -0600 Subject: [PATCH] file.managed: Allow local file sources to use source_hash Fixes #26526. --- salt/modules/file.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/salt/modules/file.py b/salt/modules/file.py index e5255a3851..460ccfaec6 100644 --- a/salt/modules/file.py +++ b/salt/modules/file.py @@ -3341,13 +3341,6 @@ def get_managed( source_sum = __salt__['cp.hash_file'](source, saltenv) if not source_sum: return '', {}, 'Source file {0} not found'.format(source) - # if its a local file - elif urlparsed_source.scheme == 'file': - file_sum = get_hash(urlparsed_source.path, form='sha256') - source_sum = {'hsum': file_sum, 'hash_type': 'sha256'} - elif source.startswith('/'): - file_sum = get_hash(source, form='sha256') - source_sum = {'hsum': file_sum, 'hash_type': 'sha256'} elif source_hash: protos = ('salt', 'http', 'https', 'ftp', 'swift', 's3') if _urlparse(source_hash).scheme in protos: @@ -3372,6 +3365,12 @@ def get_managed( ).format(source_hash) source_sum['hsum'] = comps[1].strip() source_sum['hash_type'] = comps[0].strip() + elif urlparsed_source.scheme == 'file': + file_sum = get_hash(urlparsed_source.path, form='sha256') + source_sum = {'hsum': file_sum, 'hash_type': 'sha256'} + elif source.startswith('/'): + file_sum = get_hash(source, form='sha256') + source_sum = {'hsum': file_sum, 'hash_type': 'sha256'} else: return '', {}, ('Unable to determine upstream hash of' ' source file {0}').format(source)