mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Merge pull request #39438 from cloudflare/fix_39422
file.get_managed: refetch source when file hashsum is changed
This commit is contained in:
commit
e816d6c23e
@ -3740,16 +3740,22 @@ def get_managed(
|
||||
|
||||
if source and (template or parsed_scheme in salt.utils.files.REMOTE_PROTOS):
|
||||
# Check if we have the template or remote file cached
|
||||
cache_refetch = False
|
||||
cached_dest = __salt__['cp.is_cached'](source, saltenv)
|
||||
if cached_dest and (source_hash or skip_verify):
|
||||
htype = source_sum.get('hash_type', 'sha256')
|
||||
cached_sum = get_hash(cached_dest, form=htype)
|
||||
if skip_verify or cached_sum == source_sum['hsum']:
|
||||
if cached_sum != source_sum['hsum']:
|
||||
cache_refetch = True
|
||||
elif skip_verify:
|
||||
# prev: if skip_verify or cached_sum == source_sum['hsum']:
|
||||
# but `cached_sum == source_sum['hsum']` is elliptical as prev if
|
||||
sfn = cached_dest
|
||||
source_sum = {'hsum': cached_sum, 'hash_type': htype}
|
||||
|
||||
# If we didn't have the template or remote file, let's get it
|
||||
if not sfn:
|
||||
# Similarly when the file has been updated and the cache has to be refreshed
|
||||
if not sfn or cache_refetch:
|
||||
try:
|
||||
sfn = __salt__['cp.cache_file'](source, saltenv)
|
||||
except Exception as exc:
|
||||
|
Loading…
Reference in New Issue
Block a user