mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Fix boot loop after restoring backup (#133581)
This commit is contained in:
parent
94c7d18346
commit
255f85eb2f
@ -64,6 +64,9 @@ def restore_backup_file_content(config_dir: Path) -> RestoreBackupFileContent |
|
|||||||
)
|
)
|
||||||
except (FileNotFoundError, KeyError, json.JSONDecodeError):
|
except (FileNotFoundError, KeyError, json.JSONDecodeError):
|
||||||
return None
|
return None
|
||||||
|
finally:
|
||||||
|
# Always remove the backup instruction file to prevent a boot loop
|
||||||
|
instruction_path.unlink(missing_ok=True)
|
||||||
|
|
||||||
|
|
||||||
def _clear_configuration_directory(config_dir: Path, keep: Iterable[str]) -> None:
|
def _clear_configuration_directory(config_dir: Path, keep: Iterable[str]) -> None:
|
||||||
|
@ -57,11 +57,14 @@ def test_reading_the_instruction_contents(
|
|||||||
return_value=content,
|
return_value=content,
|
||||||
side_effect=side_effect,
|
side_effect=side_effect,
|
||||||
),
|
),
|
||||||
|
mock.patch("pathlib.Path.unlink", autospec=True) as unlink_mock,
|
||||||
):
|
):
|
||||||
read_content = backup_restore.restore_backup_file_content(
|
config_path = Path(get_test_config_dir())
|
||||||
Path(get_test_config_dir())
|
read_content = backup_restore.restore_backup_file_content(config_path)
|
||||||
)
|
|
||||||
assert read_content == expected
|
assert read_content == expected
|
||||||
|
unlink_mock.assert_called_once_with(
|
||||||
|
config_path / ".HA_RESTORE", missing_ok=True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_restoring_backup_that_does_not_exist() -> None:
|
def test_restoring_backup_that_does_not_exist() -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user