fix(folder_scan): await NFO repair before folder rename

folder_rename_service depends on clean NFO files but repair tasks
were fire-and-forget. Now collect all repair tasks and await them
with asyncio.gather before validate_and_rename_series_folders runs.

Also update tests that mock asyncio.create_task to also mock
asyncio.gather since perform_nfo_repair_scan now awaits tasks.
This commit is contained in:
2026-06-01 21:37:28 +02:00
parent c58b42dfa5
commit a54c285994
2 changed files with 29 additions and 10 deletions

View File

@@ -816,11 +816,14 @@ class TestPerformNfoRepairScan:
return_value=mock_repair_service,
), patch(
"asyncio.create_task"
) as mock_create_task:
) as mock_create_task, patch(
"asyncio.gather", new_callable=AsyncMock
) as mock_gather:
mock_factory_cls.return_value.create.return_value = MagicMock()
await perform_nfo_repair_scan(background_loader=AsyncMock())
mock_create_task.assert_called_once()
mock_gather.assert_called_once()
@pytest.mark.asyncio
async def test_skips_complete_series(self, tmp_path):
@@ -876,8 +879,11 @@ class TestPerformNfoRepairScan:
return_value=mock_repair_service,
), patch(
"asyncio.create_task"
) as mock_create_task:
) as mock_create_task, patch(
"asyncio.gather", new_callable=AsyncMock
) as mock_gather:
mock_factory_cls.return_value.create.return_value = MagicMock()
await perform_nfo_repair_scan(background_loader=None)
mock_create_task.assert_called_once()
mock_gather.assert_called_once()