Skip to content

Commit

Permalink
feat(archive-output): improved study output deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent-laporte-pro committed Jun 5, 2024
1 parent a5cd030 commit 4373026
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions antarest/study/storage/rawstudy/raw_study_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 4373026

Please sign in to comment.