Skip to content

Commit

Permalink
build: add missing flush()
Browse files Browse the repository at this point in the history
The stuff would be written, however not flushed and causing tar
operation to fail.

Signed-off-by: Paul Spooren <[email protected]>
  • Loading branch information
aparcar committed Apr 2, 2024
1 parent 67b98f5 commit 6a11826
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
23 changes: 8 additions & 15 deletions asu/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pathlib import Path
from re import match
from shutil import unpack_archive
from tarfile import TarFile
from tempfile import NamedTemporaryFile

import nacl.signing
Expand Down Expand Up @@ -286,25 +287,17 @@ def run_container(
logging.debug(f"Container tar: {container_tar}")

host_tar = NamedTemporaryFile(delete=True)
logging.debug(f"Host tar: {host_tar}")
logging.debug(f"Copying {container_tar} to {host_tar}")

host_tar.write(b"".join(container_tar))
for data in container_tar:
host_tar.write(data)
host_tar.flush()

logging.debug(f"Copied {container_tar} to {host_tar}")

# check if the tar is empty
if host_tar.tell():
unpack_archive(
host_tar.name,
copy[1],
"tar",
)
logging.debug(f"Unpacked {host_tar} to {copy[1]}")
else:
logging.warning(f"Empty tar: {host_tar}")
returncode = 1
tar_file = TarFile(host_tar.name)
tar_file.extractall(copy[1])

host_tar.close()

logging.debug(f"Closed {host_tar}")

try:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ prometheus-client = ">=0.13.1,<0.21.0"
gunicorn = ">=20.1,<22.0"
podman = ">=4.4.1,<6.0.0"
setuptools = "^69.0.3"
boto3 = "^1.34.75"

[tool.poetry.group.dev.dependencies]
ruff = ">=0.2.2,<0.4.0"
Expand Down

0 comments on commit 6a11826

Please sign in to comment.