Fixed problem with file.managed test=True

This commit is contained in:
twangboy 2015-07-14 13:43:45 -06:00
parent 4d929071e1
commit d8957856cd
3 changed files with 4 additions and 3 deletions

View file

@ -3207,7 +3207,7 @@ def check_file_meta(
if contents is not None:
# Write a tempfile with the static contents
tmp = salt.utils.mkstemp(text=True)
with salt.utils.fopen(tmp, 'w') as tmp_:
with salt.utils.fopen(tmp, 'wb') as tmp_:
tmp_.write(str(contents))
# Compare the static contents with the named file
with contextlib.nested(

View file

@ -872,7 +872,8 @@ def stats(path, hash_type='md5', follow_symlinks=True):
ret['ctime'] = pstat.st_ctime
ret['size'] = pstat.st_size
ret['mode'] = str(oct(stat.S_IMODE(pstat.st_mode)))
ret['sum'] = get_sum(path, hash_type)
if hash_type:
ret['sum'] = get_sum(path, hash_type)
ret['type'] = 'file'
if stat.S_ISDIR(pstat.st_mode):
ret['type'] = 'dir'

View file

@ -1719,7 +1719,7 @@ def get_hash(path, form='md5', chunk_size=65536):
'''
try:
hash_type = getattr(hashlib, form)
except AttributeError:
except (AttributeError, TypeError):
raise ValueError('Invalid hash type: {0}'.format(form))
with salt.utils.fopen(path, 'rb') as ifile:
hash_obj = hash_type()