Skip to content

Use tenant-scoped dubbed-audio paths with traversal-safe resolution#454

Open
AJaySi wants to merge 1 commit intomainfrom
codex/refactor-dubbed_audio_dir-to-tenant-path-resolver
Open

Use tenant-scoped dubbed-audio paths with traversal-safe resolution#454
AJaySi wants to merge 1 commit intomainfrom
codex/refactor-dubbed_audio_dir-to-tenant-path-resolver

Conversation

@AJaySi
Copy link
Copy Markdown
Owner

@AJaySi AJaySi commented Mar 30, 2026

Motivation

  • Replace the hard-coded global DUBBED_AUDIO_DIR with the same tenant-first media layout used for podcast audio/video so outputs live under each user workspace.
  • Require user-scoped directory lookup and traversal-safe resolution to prevent path traversal when serving dubbed audio or cloned voice files.

Description

  • Added _get_dubbed_audio_dir(user_id, *, ensure_exists=False) to resolve per-tenant dubbed_audio directories under the podcast audio workspace and create them when required.
  • Added _resolve_dubbed_audio_file(filename, user_id) which searches tenant directories first, falls back to the legacy data/media/dubbed_audio path, and enforces traversal-safe checks before returning a file path.
  • Replaced usages of the global DUBBED_AUDIO_DIR by initializing AudioDubbingService(output_dir=...) with the tenant-specific directory and by serving files via _resolve_dubbed_audio_file(...) in /dub/audio/{filename} and /dub/voices/audio/{filename} handlers.
  • Preserved backward compatibility by including the legacy data/media/dubbed_audio directory as a final fallback read location.

Testing

  • Compiled the modified module with python -m py_compile backend/api/podcast/handlers/dubbing.py, which succeeded.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant