From 182b4eace4ae45c802ab792448da5d5c4e824115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrew=20Beveridge=20=E2=98=84=EF=B8=8F?= Date: Thu, 15 Oct 2026 02:53:21 -0400 Subject: [PATCH] fix(tenant): second Dropbox pass keeps the tenant track-code prefix (v0.273.2) (#1159) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Found by verifying a real Vocal Star portal job in prod after #1158 (job `0976cc34`, code `E2E4635623`). The delivery folder had **both** `E2E4635623 - Artist - Title (…)` and plain `Artist - Title (…)` copies of every file. The cause: `video_worker._handle_native_distribution` re-uploads the folder after the orchestrator (adding `stems/` and `lyrics/`, with `skip_unchanged`) without the tenant filename prefix. It now passes `filename_prefix=tenant_track_code_prefix(job)`, so both passes write the same names. The unchanged-skip then also matches, so files aren't uploaded twice. ## Testing - New test: the post-orchestrator pass passes the tenant prefix. - Backend: 6069 passed (emulator tests excluded locally). - Local CodeRabbit with `--fresh`: no findings. - Will re-verify with a real prod job after deploy by listing the Dropbox folder. @coderabbitai ignore 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Gp5fBmsmWJxgkEHb4JfhXR Co-authored-by: Claude Opus 5.5 --- backend/tests/test_admin_rerender.py | 22 ++++++++++++++++++++++ backend/workers/video_worker.py | 5 +++++ pyproject.toml | 2 +- 3 files changed, 28 insertions(+), 1 deletion(-) 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"