rules: write empty file if there are no rules to save

This commit is contained in:
Peter F. Patel-Schneider 2024-01-23 07:07:30 -05:00
parent f8a462dbe5
commit 0db84f5aa4
1 changed files with 2 additions and 1 deletions

View File

@ -1545,6 +1545,7 @@ def _save_config_rule_file(file_name=_file_path):
_log.info('saving %d rule(s) to %s', len(rules_to_save), file_name)
try:
with open(file_name, 'w') as f:
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: