Adiciona limpeza de arquivos apos sucesso ou falha

This commit is contained in:
LeoMortari
2025-10-29 23:58:06 -03:00
parent ae8b228ea1
commit 87c6a5e27c
2 changed files with 20 additions and 20 deletions

View File

@@ -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,