From 2470ad11f306646120051278fc4e87e731b2eac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Thu, 2 May 2024 21:07:19 +0200 Subject: [PATCH] post-process-oabi: Flush tempfile before using it The NamedTemporaryFile is buffered by default, so there might be data left in the buffer when shutil.copyfileobj() completes. This would then result in TarFile.extractall() failing due to trying to read from an incomplete archive. --- post-process-oabi.py | 1 + 1 file changed, 1 insertion(+) diff --git a/post-process-oabi.py b/post-process-oabi.py index ff1c7c2..061b90e 100755 --- a/post-process-oabi.py +++ b/post-process-oabi.py @@ -35,6 +35,7 @@ def main(): with urllib.request.urlopen(arm64e_sdk_url) as response, \ tempfile.NamedTemporaryFile(suffix=".tar.xz") as archive: shutil.copyfileobj(response, archive) + archive.flush() arm64e_artifact_path = Path(archive.name) with tempfile.TemporaryDirectory() as patched_artifact_dir: