From f29c4b0103c5c8e816e0912932b9c288f7fa3646 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Mon, 11 Nov 2024 11:43:19 +0100 Subject: [PATCH] Only attempt to find and remove files when directories exist. (#56) --- hooks/pre-command | 4 +++- hooks/pre-exit | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/hooks/pre-command b/hooks/pre-command index 43f4493..5dc0bc8 100755 --- a/hooks/pre-command +++ b/hooks/pre-command @@ -46,7 +46,9 @@ if [[ "${BUILDKITE_PLUGIN_JULIA_ISOLATED_DEPOT:-true}" == "true" ]]; then # Clean out any stale pidfiles that may have come from a cancelled run, # as it's not possible for another job to be running concurrently. - find "${JULIA_DEPOT_PATH}"/compiled -name '*.pidfile' -delete + if [[ -d "${JULIA_DEPOT_PATH}"/compiled ]]; then + find "${JULIA_DEPOT_PATH}"/compiled -name '*.pidfile' -delete + fi fi # Mark the depot as in-use by touching it diff --git a/hooks/pre-exit b/hooks/pre-exit index 223ede9..f76fac3 100755 --- a/hooks/pre-exit +++ b/hooks/pre-exit @@ -17,11 +17,14 @@ echo "--- :broom: Performing clean-up" echo "Removing coverage files" # Once JuliaLang/julia#26573 has been fixed, this should no longer be necessary. -find "${CACHE_DIR}"/julia_installs -name "*.jl.*.cov" -type f -delete || true +if [[ -d "${CACHE_DIR}"/julia_installs ]]; then + find "${CACHE_DIR}"/julia_installs -name "*.jl.*.cov" -type f -delete +fi # Some packages check coverage files in, so only remove writable ones -if [[ "${BUILDKITE_PLUGIN_JULIA_ISOLATED_DEPOT:-true}" == "true" ]]; then - find "${JULIA_DEPOT_PATH}"/packages -name "*.jl.*.cov" -type f -perm -200 -delete || true +if [[ "${BUILDKITE_PLUGIN_JULIA_ISOLATED_DEPOT:-true}" == "true" && \ + -d "${JULIA_DEPOT_PATH}"/packages ]]; then + find "${JULIA_DEPOT_PATH}"/packages -name "*.jl.*.cov" -type f -perm -200 -delete fi