mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 06:47:09 +00:00
Correct backup date when reading a backup created by supervisor (#138860)
This commit is contained in:
parent
eb6993f0a8
commit
ad7780291e
@ -104,12 +104,15 @@ def read_backup(backup_path: Path) -> AgentBackup:
|
||||
bool, homeassistant.get("exclude_database", False)
|
||||
)
|
||||
|
||||
extra_metadata = cast(dict[str, bool | str], data.get("extra", {}))
|
||||
date = extra_metadata.get("supervisor.backup_request_date", data["date"])
|
||||
|
||||
return AgentBackup(
|
||||
addons=addons,
|
||||
backup_id=cast(str, data["slug"]),
|
||||
database_included=database_included,
|
||||
date=cast(str, data["date"]),
|
||||
extra_metadata=cast(dict[str, bool | str], data.get("extra", {})),
|
||||
date=cast(str, date),
|
||||
extra_metadata=extra_metadata,
|
||||
folders=folders,
|
||||
homeassistant_included=homeassistant_included,
|
||||
homeassistant_version=homeassistant_version,
|
||||
|
@ -89,6 +89,28 @@ from tests.common import get_fixture_path
|
||||
size=1234,
|
||||
),
|
||||
),
|
||||
# Check the backup_request_date is used as date if present
|
||||
(
|
||||
b'{"compressed":true,"date":"2024-12-01T00:00:00.000000-00:00","homeassistant":'
|
||||
b'{"exclude_database":true,"version":"2024.12.0.dev0"},"name":"test",'
|
||||
b'"extra":{"supervisor.backup_request_date":"2025-12-01T00:00:00.000000-00:00"},'
|
||||
b'"protected":true,"slug":"455645fe","type":"partial","version":2}',
|
||||
AgentBackup(
|
||||
addons=[],
|
||||
backup_id="455645fe",
|
||||
date="2025-12-01T00:00:00.000000-00:00",
|
||||
database_included=False,
|
||||
extra_metadata={
|
||||
"supervisor.backup_request_date": "2025-12-01T00:00:00.000000-00:00"
|
||||
},
|
||||
folders=[],
|
||||
homeassistant_included=True,
|
||||
homeassistant_version="2024.12.0.dev0",
|
||||
name="test",
|
||||
protected=True,
|
||||
size=1234,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_read_backup(backup_json_content: bytes, expected_backup: AgentBackup) -> None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user