Avoid string manipulations in hassio backup reader/writer (#133339)

This commit is contained in:
Erik Montnemery 2024-12-16 09:47:49 +01:00 committed by GitHub
parent 22d03afb9b
commit 06f6869da5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -175,7 +175,7 @@ class SupervisorBackupReaderWriter(BackupReaderWriter):
hassio_agents: list[SupervisorBackupAgent] = [ hassio_agents: list[SupervisorBackupAgent] = [
cast(SupervisorBackupAgent, manager.backup_agents[agent_id]) cast(SupervisorBackupAgent, manager.backup_agents[agent_id])
for agent_id in agent_ids for agent_id in agent_ids
if agent_id.startswith(DOMAIN) if manager.backup_agents[agent_id].domain == DOMAIN
] ]
locations = {agent.location for agent in hassio_agents} locations = {agent.location for agent in hassio_agents}
@ -254,7 +254,7 @@ class SupervisorBackupReaderWriter(BackupReaderWriter):
hassio_agents: list[SupervisorBackupAgent] = [ hassio_agents: list[SupervisorBackupAgent] = [
cast(SupervisorBackupAgent, manager.backup_agents[agent_id]) cast(SupervisorBackupAgent, manager.backup_agents[agent_id])
for agent_id in agent_ids for agent_id in agent_ids
if agent_id.startswith(DOMAIN) if manager.backup_agents[agent_id].domain == DOMAIN
] ]
locations = {agent.location for agent in hassio_agents} locations = {agent.location for agent in hassio_agents}
@ -305,7 +305,8 @@ class SupervisorBackupReaderWriter(BackupReaderWriter):
else None else None
) )
if not agent_id.startswith(DOMAIN): manager = self._hass.data[DATA_MANAGER]
if manager.backup_agents[agent_id].domain != DOMAIN:
# Download the backup to the supervisor. Supervisor will clean up the backup # Download the backup to the supervisor. Supervisor will clean up the backup
# two days after the restore is done. # two days after the restore is done.
await self.async_receive_backup( await self.async_receive_backup(