Skip to content

Commit 33d0fef

Browse files
committed
Do not download binary when it already exist
1 parent 663f9d4 commit 33d0fef

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

hooks/_common.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,10 @@ function common::populate_tool_cache {
573573
local -r cache_dir="$5"
574574
local -r cached_bin="$6"
575575

576+
if [[ -x $cached_bin ]]; then
577+
return 0
578+
fi
579+
576580
local tmp_dir
577581
tmp_dir=$(mktemp -d "${cache_dir}.XXXXXXXXXX") || {
578582
common::colorify "red" "ERROR: Failed to create a temp directory for '$tool_name' version '$version'."
@@ -595,12 +599,6 @@ function common::populate_tool_cache {
595599
return 1
596600
fi
597601

598-
# Someone else may have already won the race - use their result.
599-
if [[ -x $cached_bin ]]; then
600-
rm -rf "$tmp_dir"
601-
return 0
602-
fi
603-
604602
# Atomic `rename(2)`: both sides are plain files, so a concurrent
605603
# reader never sees a partial write.
606604
if ! mv "$tmp_dir/$(basename "$cached_bin")" "$cached_bin" 2> /dev/null; then

0 commit comments

Comments
 (0)