Skip to content

Commit

Permalink
Fix backup dir not existing (#134506)
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob authored and frenck committed Jan 3, 2025
1 parent 59a3fe8 commit e1f6475
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions homeassistant/components/backup/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,7 @@ async def async_receive_backup(
if self._local_agent_id in agent_ids:
local_agent = manager.local_backup_agents[self._local_agent_id]
tar_file_path = local_agent.get_backup_path(backup.backup_id)
await async_add_executor_job(make_backup_dir, tar_file_path.parent)
await async_add_executor_job(shutil.move, temp_file, tar_file_path)
else:
tar_file_path = temp_file
Expand Down
4 changes: 4 additions & 0 deletions tests/components/backup/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,9 @@ async def test_receive_backup(

with (
patch("pathlib.Path.open", open_mock),
patch(
"homeassistant.components.backup.manager.make_backup_dir"
) as make_backup_dir_mock,
patch("shutil.move") as move_mock,
patch(
"homeassistant.components.backup.manager.read_backup",
Expand All @@ -1412,6 +1415,7 @@ async def test_receive_backup(

assert resp.status == 201
assert open_mock.call_count == open_call_count
assert make_backup_dir_mock.call_count == move_call_count + 1
assert move_mock.call_count == move_call_count
for index, name in enumerate(move_path_names):
assert move_mock.call_args_list[index].args[1].name == name
Expand Down

0 comments on commit e1f6475

Please sign in to comment.