Skip to content

Commit

Permalink
Discard broken S3 downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
bradleyayers committed Oct 27, 2023
1 parent 9df04eb commit c8e7b29
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/backends/s3.bash
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,15 @@ function restore() {
fi

if [[ ! "${BK_AWS_FOUND}" =~ (false) ]]; then
aws s3 cp ${BK_CUSTOM_AWS_ARGS} "s3://${BUCKET}/${TAR_FILE}" .
TMP_FILE="$(mktemp)"
aws s3 cp ${BK_CUSTOM_AWS_ARGS} "s3://${BUCKET}/${TAR_FILE}" "${TMP_FILE}" || s3_download_failed=true
if ${s3_download_failed:-false}; then
echo -e "AWS download failed, skipping cache restore..."
exit 0
else
mv "${TMP_FILE}" "${TAR_FILE}"
fi

[ "${BK_CACHE_SAVE_CACHE}" == "true" ] && cp "${TAR_FILE}" "${BK_CACHE_LOCAL_PATH}/${TAR_FILE}"
tar ${BK_TAR_EXTRACT_ARGS} "${TAR_FILE}" -C .
else
Expand Down

0 comments on commit c8e7b29

Please sign in to comment.