Skip to content

Commit

Permalink
backend: tar also reviews for download
Browse files Browse the repository at this point in the history
  • Loading branch information
nikromen committed Oct 14, 2024
1 parent 495b447 commit a2ad555
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion backend/src/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def download_results():

tmp_dir = Path(tempfile.mkdtemp())
tar_name = f"results-{int(datetime.now().timestamp())}.tar.gz"
tar_path = make_tar(tar_name, Path(FEEDBACK_DIR), tmp_dir)
tar_path = make_tar(tar_name, [Path(FEEDBACK_DIR), Path(REVIEWS_DIR)], tmp_dir)

def cleanup():
os.unlink(tar_path)
Expand Down
7 changes: 4 additions & 3 deletions backend/src/spells.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,22 @@ def get_temporary_dir() -> Iterator[Path]:
shutil.rmtree(temp_dir)


def make_tar(name: str, source: Path, destination: Path) -> Path:
def make_tar(name: str, sources: list[Path], destination: Path) -> Path:
"""
Make tar from source path.
Args:
name: Name of the tar file
source: Source to be tarred
sources: Sources to be tarred
destination: Folder where to put tar file
Returns:
Path where to find a tar file.
"""
tar_path = destination / name
with tarfile.open(tar_path, "w:gz") as tar_f:
tar_f.add(source, arcname="results")
for source in sources:
tar_f.add(source, arcname=f"results/{source.name}")

return tar_path

Expand Down

0 comments on commit a2ad555

Please sign in to comment.