Merge pull request #13997 from hyuraku/add-error-log-for-download-formula.json

add error log of download `formula.json`
This commit is contained in:
Mike McQuaid 2022-10-14 17:35:45 +01:00 committed by GitHub
commit 34979a33d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -754,6 +754,10 @@ EOS
if [[ -n "${HOMEBREW_INSTALL_FROM_API}" ]] if [[ -n "${HOMEBREW_INSTALL_FROM_API}" ]]
then then
mkdir -p "${HOMEBREW_CACHE}/api" mkdir -p "${HOMEBREW_CACHE}/api"
if [[ -f "${HOMEBREW_CACHE}/api/formula.json" ]]
then
INITIAL_JSON_BYTESIZE="$(wc -c "${HOMEBREW_CACHE}"/api/formula.json)"
fi
curl \ curl \
"${CURL_DISABLE_CURLRC_ARGS[@]}" \ "${CURL_DISABLE_CURLRC_ARGS[@]}" \
--fail --compressed --silent --max-time 5 \ --fail --compressed --silent --max-time 5 \
@ -761,8 +765,17 @@ EOS
--time-cond "${HOMEBREW_CACHE}/api/formula.json" \ --time-cond "${HOMEBREW_CACHE}/api/formula.json" \
--user-agent "${HOMEBREW_USER_AGENT_CURL}" \ --user-agent "${HOMEBREW_USER_AGENT_CURL}" \
"https://formulae.brew.sh/api/formula.json" "https://formulae.brew.sh/api/formula.json"
# TODO: we probably want to print an error if this fails. curl_exit_code=$?
# TODO: set HOMEBREW_UPDATED or HOMEBREW_UPDATE_FAILED if [[ ${curl_exit_code} -eq 0 ]]
then
CURRENT_JSON_BYTESIZE="$(wc -c "${HOMEBREW_CACHE}"/api/formula.json)"
if [[ "${INITIAL_JSON_BYTESIZE}" != "${CURRENT_JSON_BYTESIZE}" ]]
then
HOMEBREW_UPDATED="1"
fi
else
echo "Failed to download formula.json!" >>"${update_failed_file}"
fi
fi fi
safe_cd "${HOMEBREW_REPOSITORY}" safe_cd "${HOMEBREW_REPOSITORY}"