mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 17:57:55 +00:00
Fix logic in backup retention filter (#133654)
This commit is contained in:
parent
9f43a7a17b
commit
10478f4ca5
@ -467,7 +467,7 @@ async def delete_backups_exceeding_configured_count(manager: BackupManager) -> N
|
|||||||
sorted(
|
sorted(
|
||||||
backups.items(),
|
backups.items(),
|
||||||
key=lambda backup_item: backup_item[1].date,
|
key=lambda backup_item: backup_item[1].date,
|
||||||
)[: len(backups) - manager.config.data.retention.copies]
|
)[: max(len(backups) - manager.config.data.retention.copies, 0)]
|
||||||
)
|
)
|
||||||
|
|
||||||
await _delete_filtered_backups(manager, _backups_filter)
|
await _delete_filtered_backups(manager, _backups_filter)
|
||||||
|
@ -1331,6 +1331,35 @@ async def test_config_schedule_logic(
|
|||||||
0,
|
0,
|
||||||
[],
|
[],
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
{
|
||||||
|
"type": "backup/config/update",
|
||||||
|
"create_backup": {"agent_ids": ["test.test-agent"]},
|
||||||
|
"retention": {"copies": 3, "days": None},
|
||||||
|
"schedule": "daily",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backup-1": MagicMock(
|
||||||
|
date="2024-11-10T04:45:00+01:00",
|
||||||
|
with_automatic_settings=True,
|
||||||
|
spec=ManagerBackup,
|
||||||
|
),
|
||||||
|
"backup-2": MagicMock(
|
||||||
|
date="2024-11-11T04:45:00+01:00",
|
||||||
|
with_automatic_settings=True,
|
||||||
|
spec=ManagerBackup,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
"2024-11-11T04:45:00+01:00",
|
||||||
|
"2024-11-12T04:45:00+01:00",
|
||||||
|
"2024-11-12T04:45:00+01:00",
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
[],
|
||||||
|
),
|
||||||
(
|
(
|
||||||
{
|
{
|
||||||
"type": "backup/config/update",
|
"type": "backup/config/update",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user