If lockfile found, use cached download

This commit is contained in:
thespad
2024-12-22 15:49:43 +00:00
parent 299f679e01
commit e84b25458c
+11 -7
View File
@@ -381,16 +381,17 @@ run_mods() {
for ((i = 5 ; i < 21 ; i=i*2 )); do for ((i = 5 ; i < 21 ; i=i*2 )); do
sleep $i sleep $i
if [[ ! -f "/modcache/${FILENAME}.lock" ]]; then if [[ ! -f "/modcache/${FILENAME}.lock" ]]; then
SKIP_MOD_DOWNLOAD=true
break break
elif [[ $i == 20 ]]; then elif [[ $i == 20 ]]; then
write_mod_error "${DOCKER_MOD} timed out waiting for lock, skipping\n\tIf no other containers are using this mod you may need to delete /modcache/${FILENAME}.lock" write_mod_error "${DOCKER_MOD} timed out waiting for lock, skipping\n\tIf no other containers are using this mod you may need to delete /modcache/${FILENAME}.lock"
SKIP_MOD_DOWNLOAD=true SKIP_MOD=true
fi fi
done done
fi fi
if [[ "${SKIP_MOD_DOWNLOAD}" == "true" ]]; then if [[ "${SKIP_MOD}" == "true" ]]; then
continue continue
fi elif [[ "${SKIP_MOD_DOWNLOAD}" != "true" ]]; then
# Download and extract layer to / # Download and extract layer to /
touch "/modcache/${FILENAME}.lock" touch "/modcache/${FILENAME}.lock"
curl -f --retry 5 --retry-max-time 30 --retry-all-errors \ curl -f --retry 5 --retry-max-time 30 --retry-all-errors \
@@ -400,12 +401,15 @@ run_mods() {
--user-agent "${MOD_UA}" \ --user-agent "${MOD_UA}" \
"${BLOB_URL}${SHALAYER}" -o \ "${BLOB_URL}${SHALAYER}" -o \
"/modcache/${FILENAME}.tar.xz" "/modcache/${FILENAME}.tar.xz"
if ! tar -tzf "/modcache/${FILENAME}.tar.xz" >/dev/null 2>&1; then
write_mod_error "Invalid tarball, could not download ${DOCKER_MOD} from ${REGISTRY}"
rm "/modcache/${FILENAME}.lock" || write_mod_error "Failed to delete lock file /modcache/${FILENAME}.lock"
continue
fi fi
fi fi
if ! tar -tzf "/modcache/${FILENAME}.tar.xz" >/dev/null 2>&1; then
write_mod_error "Invalid tarball for ${DOCKER_MOD}, skipping"
if [[ -f "/modcache/${FILENAME}.lock" ]]; then
rm "/modcache/${FILENAME}.lock" || write_mod_error "Failed to delete lock file /modcache/${FILENAME}.lock"
fi
continue
fi
write_mod_info "Installing ${DOCKER_MOD}" write_mod_info "Installing ${DOCKER_MOD}"
mkdir -p /tmp/mod mkdir -p /tmp/mod
tar xzf "/modcache/${FILENAME}.tar.xz" -C /tmp/mod tar xzf "/modcache/${FILENAME}.tar.xz" -C /tmp/mod