From 04b7f737183e9f8ff012ff6aff33f39fa69f7ad0 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Wed, 13 Mar 2019 15:01:35 -0400 Subject: [PATCH] Clean up the downloaded file if it's corrupted --- pyodide_build/buildpkg.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pyodide_build/buildpkg.py b/pyodide_build/buildpkg.py index 63421a1ba..88caae1cb 100755 --- a/pyodide_build/buildpkg.py +++ b/pyodide_build/buildpkg.py @@ -42,10 +42,14 @@ def check_checksum(path, pkg): def download_and_extract(buildpath, packagedir, pkg, args): tarballpath = buildpath / Path(pkg['source']['url']).name if not tarballpath.is_file(): - subprocess.run([ - 'wget', '-q', '-O', str(tarballpath), pkg['source']['url'] - ], check=True) - check_checksum(tarballpath, pkg) + try: + subprocess.run([ + 'wget', '-q', '-O', str(tarballpath), pkg['source']['url'] + ], check=True) + check_checksum(tarballpath, pkg) + except Exception: + tarballpath.unlink() + raise srcpath = buildpath / packagedir if not srcpath.is_dir(): shutil.unpack_archive(str(tarballpath), str(buildpath))