diff --git a/video_render/media.py b/video_render/media.py index a79dd4f..7fb878e 100644 --- a/video_render/media.py +++ b/video_render/media.py @@ -38,7 +38,7 @@ class MediaPreparer: existing_children = list(workspace_dir.iterdir()) if existing_children: logger.info("Limpando workspace existente para %s", sanitized_name) - # remove_paths(existing_children) + remove_paths(existing_children) destination_name = f"{sanitized_name}{source_path.suffix.lower()}" working_video_path = workspace_dir / destination_name @@ -46,9 +46,9 @@ class MediaPreparer: logger.info("Cópia do vídeo criada em %s", working_video_path) output_dir = ensure_workspace(self.settings.outputs_dir, sanitized_name) - # existing_outputs = list(output_dir.iterdir()) - # if existing_outputs: - # remove_paths(existing_outputs) + existing_outputs = list(output_dir.iterdir()) + if existing_outputs: + remove_paths(existing_outputs) audio_path = workspace_dir / "audio.wav" extract_audio_to_wav(working_video_path, audio_path) diff --git a/video_render/pipeline.py b/video_render/pipeline.py index 4401771..3c4f348 100644 --- a/video_render/pipeline.py +++ b/video_render/pipeline.py @@ -221,24 +221,24 @@ class VideoPipeline: def _handle_failure(self, context: PipelineContext, exc: Exception) -> Dict[str, Any]: logger.error("Erro na pipeline: %s", exc) - # cleanup_targets: List[Path] = [] + cleanup_targets: List[Path] = [] - # if context.workspace: - # cleanup_targets.append(context.workspace.workspace_dir) - # cleanup_targets.append(context.workspace.output_dir) - # original_path = context.workspace.source_path - # if original_path.exists(): - # cleanup_targets.append(original_path) - # else: - # sanitized = sanitize_filename(Path(context.job.filename).stem) - # job_output_dir = self.settings.outputs_dir / sanitized - # if job_output_dir.exists(): - # cleanup_targets.append(job_output_dir) - # original_path = self.settings.videos_dir / context.job.filename - # if original_path.exists(): - # cleanup_targets.append(original_path) + if context.workspace: + cleanup_targets.append(context.workspace.workspace_dir) + cleanup_targets.append(context.workspace.output_dir) + original_path = context.workspace.source_path + if original_path.exists(): + cleanup_targets.append(original_path) + else: + sanitized = sanitize_filename(Path(context.job.filename).stem) + job_output_dir = self.settings.outputs_dir / sanitized + if job_output_dir.exists(): + cleanup_targets.append(job_output_dir) + original_path = self.settings.videos_dir / context.job.filename + if original_path.exists(): + cleanup_targets.append(original_path) - # remove_paths(cleanup_targets) + remove_paths(cleanup_targets) return { "hasError": True,