diff --git a/backend/tests/test_admin_rerender.py b/backend/tests/test_admin_rerender.py index 407aeb76..a05abc2e 100644 --- a/backend/tests/test_admin_rerender.py +++ b/backend/tests/test_admin_rerender.py @@ -1331,6 +1331,28 @@ class TestLegacyDiscordAndBrandCode: assert result["brand_code"] == "NOMAD-1234" + @pytest.mark.asyncio + async def test_native_distribution_second_pass_keeps_tenant_prefix(self): + """The post-orchestrator Dropbox pass must use the same " - " names, or + it adds an unprefixed copy of every file next to the prefixed ones.""" + from backend.workers import video_worker + + job = _job(review_token=None, state_data={}) + job.keep_brand_code = "VS6588" + job.tenant_id = "vocalstar" + result = {"brand_code": None} + dist = SimpleNamespace(dropbox_path="/T/Tracks-VocalStar", brand_prefix="VSTAR", gdrive_folder_id=None, + enable_youtube_upload=False) + dropbox = MagicMock(is_configured=True) + with patch("backend.services.job_defaults_service.get_effective_distribution_for_job", return_value=dist), \ + patch("backend.services.dropbox_service.get_dropbox_service", return_value=dropbox): + await video_worker._handle_native_distribution( + job_id="job123", job=job, job_log=MagicMock(), job_manager=MagicMock(), + temp_dir="/tmp/x", result=result, storage=None, + ) + assert dropbox.upload_folder.call_args.kwargs["filename_prefix"] == "VS6588 - " + + # --- R2#9: admin delete-outputs uses the shared helpers --------------------------------- class TestDeleteOutputsSharedHelpers: diff --git a/backend/workers/video_worker.py b/backend/workers/video_worker.py index 7b382f09..1379b2e3 100644 --- a/backend/workers/video_worker.py +++ b/backend/workers/video_worker.py @@ -1308,10 +1308,15 @@ async def _handle_native_distribution( # The orchestrator already uploaded this folder minus stems/ and # lyrics/ (prepared just above) — only send what's new or changed # instead of re-uploading every file a second time. + from backend.workers.video_worker_orchestrator import tenant_track_code_prefix + dropbox.upload_folder( temp_dir, remote_folder, exclude_suffixes=dropbox_skip_suffixes_for(dropbox_path), skip_unchanged=True, + # Same names as the orchestrator's pass (tenant " - " prefix), + # or this pass would add an unprefixed copy of every file. + filename_prefix=tenant_track_code_prefix(job), ) # Create sharing link diff --git a/pyproject.toml b/pyproject.toml index 1cd4b9fe..a984941e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "karaoke-gen" -version = "0.273.1" +version = "0.273.2" description = "Generate karaoke videos with synchronized lyrics. Handles the entire process from downloading audio and lyrics to creating the final video with title screens." authors = ["Andrew Beveridge "] license = "MIT"