Skip to content

Commit

Permalink
zip
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBelthle committed Jul 19, 2024
1 parent c2268e6 commit 433cbdc
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions antarest/study/storage/study_download_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,23 +361,23 @@ def write_inside_archive(path: Path, file_type: ExportFormat, matrix: MatrixAggr

f.writestr(f"{ts_data.name}.csv", bytes_to_writes)
else:
with tarfile.open(path, mode="w:gz") as f:
for ts_data in matrix.data:
bytes_to_writes = StudyDownloader.create_csv_file(ts_data, matrix)
file_count += 1
total_size += len(bytes_to_writes)
if total_size > max_size:
raise ValueError("L'archive dépasse la taille maximale autorisée.")
if file_count > max_files:
raise ValueError("L'archive contient trop de fichiers.")

data_file = BytesIO(bytes_to_writes)
data_file.seek(0, os.SEEK_END)
file_size = data_file.tell()
data_file.seek(0)
info = tarfile.TarInfo(name=f"{ts_data.name}.csv")
info.size = file_size
f.addfile(tarinfo=info, fileobj=data_file)
f= tarfile.open(path, mode="w:gz")
for ts_data in matrix.data:
bytes_to_writes = StudyDownloader.create_csv_file(ts_data, matrix)
file_count += 1
total_size += len(bytes_to_writes)
if total_size > max_size:
raise ValueError("L'archive dépasse la taille maximale autorisée.")
if file_count > max_files:
raise ValueError("L'archive contient trop de fichiers.")

data_file = BytesIO(bytes_to_writes)
data_file.seek(0, os.SEEK_END)
file_size = data_file.tell()
data_file.seek(0)
info = tarfile.TarInfo(name=f"{ts_data.name}.csv")
info.size = file_size
f.addfile(tarinfo=info, fileobj=data_file)

@staticmethod
def create_csv_file(ts_data: TimeSeriesData, matrix: MatrixAggregationResultDTO) -> bytes:
Expand Down

0 comments on commit 433cbdc

Please sign in to comment.