Skip to content

Commit

Permalink
Check if os has chown (#18229)
Browse files Browse the repository at this point in the history
  • Loading branch information
bramkragten authored and balloob committed Nov 5, 2018
1 parent be3800d commit fb94728
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions homeassistant/util/ruamel_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,11 @@ def save_yaml(fname: str, data: JSON_TYPE) -> None:
as temp_file:
yaml.dump(data, temp_file)
os.replace(tmp_fname, fname)
try:
os.chown(fname, file_stat.st_uid, file_stat.st_gid)
except OSError:
pass
if hasattr(os, 'chown'):
try:
os.chown(fname, file_stat.st_uid, file_stat.st_gid)
except OSError:
pass
except YAMLError as exc:
_LOGGER.error(str(exc))
raise HomeAssistantError(exc)
Expand Down

0 comments on commit fb94728

Please sign in to comment.