mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Get rid of repetition in code by using new "refreshed" variable instead
This commit is contained in:
parent
3b1dc978e2
commit
0435a1375e
1 changed files with 6 additions and 9 deletions
|
@ -1053,15 +1053,14 @@ def installed(
|
|||
if not isinstance(version, six.string_types) and version is not None:
|
||||
version = str(version)
|
||||
|
||||
refreshed = False
|
||||
|
||||
if version is not None and version == 'latest':
|
||||
version = __salt__['pkg.latest_version'](name,
|
||||
fromrepo=fromrepo,
|
||||
refresh=refresh)
|
||||
|
||||
# Ensure that refresh doesn't occur again for the remainder of the salt run
|
||||
# (unless overriden)
|
||||
if os.path.isfile(rtag) and refresh:
|
||||
os.remove(rtag)
|
||||
refreshed = refresh
|
||||
refresh = False
|
||||
|
||||
# If version is empty, it means the latest version is installed
|
||||
|
@ -1092,10 +1091,7 @@ def installed(
|
|||
**kwargs)
|
||||
|
||||
if salt.utils.is_windows():
|
||||
# Ensure that a refresh does not re-occur for the rest of the salt run
|
||||
# (unless overriden)
|
||||
if os.path.isfile(rtag) and refresh:
|
||||
os.remove(rtag)
|
||||
refreshed = refreshed or refresh
|
||||
kwargs.pop('refresh')
|
||||
refresh = False
|
||||
|
||||
|
@ -1233,7 +1229,8 @@ def installed(
|
|||
normalize=normalize,
|
||||
**kwargs)
|
||||
|
||||
if os.path.isfile(rtag) and refresh:
|
||||
refreshed = refreshed or refresh
|
||||
if os.path.isfile(rtag) and refreshed:
|
||||
os.remove(rtag)
|
||||
except CommandExecutionError as exc:
|
||||
ret = {'name': name,
|
||||
|
|
Loading…
Add table
Reference in a new issue