Adiciona limpeza de arquivos apos sucesso ou falha
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user