CI: download dependency if the filename is the same but the checksum changed

This commit is contained in:
Megamouse
2026-01-24 12:57:11 +01:00
committed by Ani
parent fbd5bbcfa3
commit 1e0909c579
2 changed files with 30 additions and 6 deletions

View File

@@ -28,11 +28,23 @@ download_and_verify()
correctChecksum="$2"
algo="$3"
fileName="$4"
path="$DEPS_CACHE_DIR/$fileName"
for _ in 1 2 3; do
[ -e "$DEPS_CACHE_DIR/$fileName" ] || curl -fLo "$DEPS_CACHE_DIR/$fileName" "$url"
fileChecksum=$("${algo}sum" "$DEPS_CACHE_DIR/$fileName" | awk '{ print $1 }')
[ "$fileChecksum" = "$correctChecksum" ] && return 0
# Check if the file exists and the checksum is correct
if [ -e "$path" ]; then
fileChecksum=$("${algo}sum" "$path" | awk '{ print $1 }')
[ "$fileChecksum" = "$correctChecksum" ] && return 0
fi
# Otherwise download the file
curl -fLo "$path" "$url"
# Check again if the file exists and the checksum is correct
if [ -e "$path" ]; then
fileChecksum=$("${algo}sum" "$path" | awk '{ print $1 }')
[ "$fileChecksum" = "$correctChecksum" ] && return 0
fi
done
return 1;

View File

@@ -53,11 +53,23 @@ download_and_verify()
correctChecksum="$2"
algo="$3"
fileName="$4"
path="$DEPS_CACHE_DIR/$fileName"
for _ in 1 2 3; do
[ -e "$DEPS_CACHE_DIR/$fileName" ] || curl -fLo "$DEPS_CACHE_DIR/$fileName" "$url"
fileChecksum=$("${algo}sum" "$DEPS_CACHE_DIR/$fileName" | awk '{ print $1 }')
[ "$fileChecksum" = "$correctChecksum" ] && return 0
# Check if the file exists and the checksum is correct
if [ -e "$path" ]; then
fileChecksum=$("${algo}sum" "$path" | awk '{ print $1 }')
[ "$fileChecksum" = "$correctChecksum" ] && return 0
fi
# Otherwise download the file
curl -fLo "$path" "$url"
# Check again if the file exists and the checksum is correct
if [ -e "$path" ]; then
fileChecksum=$("${algo}sum" "$path" | awk '{ print $1 }')
[ "$fileChecksum" = "$correctChecksum" ] && return 0
fi
done
return 1;