states.archive: use archive.cmd_unzip when possible

cmd_unzip is preferable as python's zip module does not preserve
permissions or mtimes.  See https://bugs.python.org/issue15795.
This commit is contained in:
Justin Findlay 2016-09-23 12:56:20 -06:00
parent 928a7891b4
commit d64ae48783

View file

@ -374,7 +374,16 @@ def extracted(name,
log.debug('Extracting {0} to {1}'.format(filename, name))
if archive_format == 'zip':
files = __salt__['archive.unzip'](filename, name, trim_output=trim_output, password=password)
if password is None and salt.utils.which('unzip'):
files = __salt__['archive.cmd_unzip'](filename, name, trim_output=trim_output)
else:
# https://bugs.python.org/issue15795
if password is not None:
log.warning('Password supplied: using archive.unzip')
if not salt.utils.which('unzip'):
log.warning('Cannot find unzip command for archive.cmd_unzip:'
' using archive.unzip instead')
files = __salt__['archive.unzip'](filename, name, trim_output=trim_output, password=password)
elif archive_format == 'rar':
files = __salt__['archive.unrar'](filename, name, trim_output=trim_output)
else: