Use JSON as format for .HA_RESTORE (#129792)

* Use JSON as format for .HA_RESTORE

* Adjust bakup manager test
This commit is contained in:
Joakim Sørensen
2024-11-04 13:07:11 +01:00
committed by GitHub
parent ae06f734ce
commit 3cadc1796f
4 changed files with 7 additions and 12 deletions

View File

@ -30,11 +30,11 @@ def restore_backup_file_content(config_dir: Path) -> RestoreBackupFileContent |
"""Return the contents of the restore backup file."""
instruction_path = config_dir.joinpath(RESTORE_BACKUP_FILE)
try:
instruction_content = instruction_path.read_text(encoding="utf-8")
instruction_content = json.loads(instruction_path.read_text(encoding="utf-8"))
return RestoreBackupFileContent(
backup_file_path=Path(instruction_content.split(";")[0])
backup_file_path=Path(instruction_content["path"])
)
except FileNotFoundError:
except (FileNotFoundError, json.JSONDecodeError):
return None