Skip to content

Commit

Permalink
rules: write empty file if there are no rules to save
Browse files Browse the repository at this point in the history
  • Loading branch information
pfps committed Jan 28, 2024
1 parent f8a462d commit 0db84f5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/logitech_receiver/diversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,8 @@ def convert(elem):
_log.info('saving %d rule(s) to %s', len(rules_to_save), file_name)
try:
with open(file_name, 'w') as f:
f.write('%YAML 1.3\n') # Write version manually
if rules_to_save:
f.write('%YAML 1.3\n') # Write version manually
_yaml_dump_all(convert([r['Rule'] for r in rules_to_save]), f, **dump_settings)
except Exception as e:
_log.error('failed to save to %s\n%s', file_name, e)
Expand Down

0 comments on commit 0db84f5

Please sign in to comment.