diff --git a/antarest/study/storage/rawstudy/raw_study_service.py b/antarest/study/storage/rawstudy/raw_study_service.py index c0af08675a..ec53fb697f 100644 --- a/antarest/study/storage/rawstudy/raw_study_service.py +++ b/antarest/study/storage/rawstudy/raw_study_service.py @@ -278,23 +278,20 @@ def delete(self, metadata: RawStudy) -> None: def delete_output(self, metadata: RawStudy, output_name: str) -> None: """ - Delete output folder - Args: - metadata: study - output_name: output simulation - - Returns: + Delete output folder or archive (zip or 7z) of a study. + Args: + metadata: The study metadata. + output_name: Output name to be deleted. """ study_path = self.get_study_path(metadata) output_path = study_path / "output" / output_name - if output_path.exists() and output_path.is_dir(): + if output_path.is_dir(): shutil.rmtree(output_path, ignore_errors=True) - elif (output_path.parent / f"{output_name}.7z").exists(): - (output_path.parent / f"{output_name}.7z").unlink(missing_ok=True) else: - output_path = output_path.parent / f"{output_name}.zip" - output_path.unlink(missing_ok=True) + locations = [output_path.with_suffix(".7z"), output_path.with_suffix(".zip")] + for path in locations: + path.unlink(missing_ok=True) remove_from_cache(self.cache, metadata.id) def import_study(self, metadata: RawStudy, stream: t.BinaryIO) -> Study: