From 43f88831191ff9ffd243595b631d2be42eeb6711 Mon Sep 17 00:00:00 2001 From: Eric Froemling Date: Wed, 6 May 2020 17:15:29 -0700 Subject: [PATCH] Improved error message if trying to build with old no-longer-available cache files --- .efrocachemap | 24 ++++++++++++------------ tools/efrotools/efrocache.py | 21 ++++++++++++++++++--- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/.efrocachemap b/.efrocachemap index 8443e207..7c09c632 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -4132,16 +4132,16 @@ "assets/build/windows/x64/python.exe": "https://files.ballistica.net/cache/ba1/25/a7/dc87c1be41605eb6fefd0145144c", "assets/build/windows/x64/python37.dll": "https://files.ballistica.net/cache/ba1/b9/e4/d912f56e42e9991bcbb4c804cfcb", "assets/build/windows/x64/pythonw.exe": "https://files.ballistica.net/cache/ba1/6c/bb/b6f52c306aa4e88061510e96cefe", - "build/prefab/linux-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/3b/89/f0292f1ea5400df513a880b9d854", - "build/prefab/linux-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/64/0d/3f9e8475055791000e999463626b", - "build/prefab/linux/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/6b/33/2dc4fcca7963c565ce1a58bf9530", - "build/prefab/linux/release/ballisticacore": "https://files.ballistica.net/cache/ba1/9c/2a/2801c037eab0f01a1c0ea4f005ff", - "build/prefab/mac-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/5a/06/a8dc02074743fd851e7ff0e97689", - "build/prefab/mac-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/40/e8/855941cae0742bc82d9167d69cd6", - "build/prefab/mac/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/e8/69/47574d0db454135321eb9a575607", - "build/prefab/mac/release/ballisticacore": "https://files.ballistica.net/cache/ba1/8d/82/8800c8dde084629c766f091969e6", - "build/prefab/windows-server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/70/e2/e17c6e167a4533fa5333fa133d21", - "build/prefab/windows-server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/9c/ab/bd4e224a0eb938ecaaef7c202eb0", - "build/prefab/windows/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/6e/d1/c00daabf989d8e202368023b5141", - "build/prefab/windows/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/61/ac/76a43349a653aa8aec999161c22b" + "build/prefab/linux-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/58/b6/bcc2f3e18ea53bd2f1aaa2772c04", + "build/prefab/linux-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/75/fc/042a96f26e198fa09956d9066afd", + "build/prefab/linux/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/d4/70/648d8f577f5ebf1600c7a48e8147", + "build/prefab/linux/release/ballisticacore": "https://files.ballistica.net/cache/ba1/cf/a7/575e32f41f7f78fadf4dae70ef5f", + "build/prefab/mac-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/55/a8/5ce470cce8517e4fa69e9b8a0dfd", + "build/prefab/mac-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/f4/d1/8aa7ebc2b53d2b166ce3c60eed89", + "build/prefab/mac/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/72/a7/dc4bc9b278dcede3d901ce1a28d1", + "build/prefab/mac/release/ballisticacore": "https://files.ballistica.net/cache/ba1/6d/7a/f881cc271e035a944e2140b26944", + "build/prefab/windows-server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/e9/9a/9881db7329339a7390f567cf5b0e", + "build/prefab/windows-server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/b4/dd/7e408d15a4dc05bbbe19fdbbcded", + "build/prefab/windows/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/ca/b5/62a61052d92a03319c8671ea8fc3", + "build/prefab/windows/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/cd/fd/21a7248ea867db21f46bf78161a8" } \ No newline at end of file diff --git a/tools/efrotools/efrocache.py b/tools/efrotools/efrocache.py index 5f8b8542..3d037a73 100644 --- a/tools/efrotools/efrocache.py +++ b/tools/efrotools/efrocache.py @@ -67,7 +67,7 @@ def get_file_hash(path: str) -> str: def get_target(path: str) -> None: """Fetch a target path from the cache, downloading if need be.""" - + from efro.error import CleanError from efrotools import run with open(CACHE_MAP_NAME) as infile: efrocachemap = json.loads(infile.read()) @@ -99,7 +99,21 @@ def get_target(path: str) -> None: if not os.path.exists(local_cache_path): os.makedirs(os.path.dirname(local_cache_path), exist_ok=True) print(f'Downloading: {Clr.SBLU}{path}{Clr.RST}') - run(f'curl --silent {url} > {local_cache_path_dl}') + result = subprocess.run( + f'curl --fail --silent {url} --output {local_cache_path_dl}', + shell=True, + check=False) + + # We prune old cache files on the server, so its possible for one to + # be trying to build something the server can no longer provide. + # try to explain the situation. + if result.returncode == 22: + raise CleanError('Server gave an error.' + ' Old build files may no longer be available;' + ' make sure you are using a recent commit.') + if result.returncode != 0: + raise CleanError('Download failed; is your internet working?') + run(f'mv {local_cache_path_dl} {local_cache_path}') # Ok we should have a valid .tar.gz file in our cache dir at this point. @@ -404,7 +418,8 @@ def warm_start_cache() -> None: # downloading thousands) if not os.path.exists(CACHE_DIR_NAME): print('Downloading asset starter-cache...', flush=True) - run(f'curl {BASE_URL}startercache.tar.xz > startercache.tar.xz') + run(f'curl --fail {BASE_URL}startercache.tar.xz' + f' --output startercache.tar.xz') print('Decompressing starter-cache...', flush=True) run('tar -xf startercache.tar.xz') run(f'mv efrocache {CACHE_DIR_NAME}')