From f62fa395f7a570e1e214f6305df23032fbc43b13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Talpalaru?= Date: Wed, 26 Jan 2022 11:54:34 +0100 Subject: [PATCH] build_nim.sh: handle manual symlink deletion (#39) --- scripts/build_nim.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/build_nim.sh b/scripts/build_nim.sh index c639966..49e35d6 100755 --- a/scripts/build_nim.sh +++ b/scripts/build_nim.sh @@ -89,8 +89,11 @@ nim_needs_rebuilding() { cp -a "$CI_CACHE"/* "$NIM_DIR"/bin/ || true # let this one fail with an empty cache dir fi - # compare the last built commit to the one requested - if [[ -e "${NIM_DIR}/bin/last_built_commit" && "$(cat "${NIM_DIR}/bin/last_built_commit")" == "${NIM_COMMIT_HASH}" ]]; then + # Compare the last built commit to the one requested. + # Handle the scenario where our symlink is manually deleted by the user. + if [[ -e "${NIM_DIR}/bin/last_built_commit" && \ + -e "${NIM_DIR}/bin/nim${EXE_SUFFIX}" && \ + "$(cat "${NIM_DIR}/bin/last_built_commit")" == "${NIM_COMMIT_HASH}" ]]; then return $NO_REBUILD elif [[ -e "${NIM_DIR}/bin/nim_commit_${NIM_COMMIT_HASH}" ]]; then # we built the requested commit in the past, so we simply reuse it