mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
PY3: Ensure binary contents work with file.managed
This commit is contained in:
parent
5d98a8bedd
commit
e3c969da81
1 changed files with 6 additions and 6 deletions
|
@ -5230,12 +5230,12 @@ def manage_file(name,
|
|||
if salt.utils.platform.is_windows():
|
||||
contents = os.linesep.join(
|
||||
_splitlines_preserving_trailing_newline(contents))
|
||||
with salt.utils.files.fopen(tmp, 'w') as tmp_:
|
||||
with salt.utils.files.fopen(tmp, 'wb') as tmp_:
|
||||
if encoding:
|
||||
log.debug('File will be encoded with {0}'.format(encoding))
|
||||
log.debug('File will be encoded with %s', encoding)
|
||||
tmp_.write(contents.encode(encoding=encoding, errors=encoding_errors))
|
||||
else:
|
||||
tmp_.write(salt.utils.stringutils.to_str(contents))
|
||||
tmp_.write(salt.utils.stringutils.to_bytes(contents))
|
||||
|
||||
try:
|
||||
differences = get_diff(
|
||||
|
@ -5438,12 +5438,12 @@ def manage_file(name,
|
|||
if salt.utils.platform.is_windows():
|
||||
contents = os.linesep.join(
|
||||
_splitlines_preserving_trailing_newline(contents))
|
||||
with salt.utils.files.fopen(tmp, 'w') as tmp_:
|
||||
with salt.utils.files.fopen(tmp, 'wb') as tmp_:
|
||||
if encoding:
|
||||
log.debug('File will be encoded with {0}'.format(encoding))
|
||||
log.debug('File will be encoded with %s', encoding)
|
||||
tmp_.write(contents.encode(encoding=encoding, errors=encoding_errors))
|
||||
else:
|
||||
tmp_.write(salt.utils.stringutils.to_str(contents))
|
||||
tmp_.write(salt.utils.stringutils.to_bytes(contents))
|
||||
|
||||
# Copy into place
|
||||
salt.utils.files.copyfile(tmp,
|
||||
|
|
Loading…
Add table
Reference in a new issue