fix(release): report what a failed upload actually means
The first real 1.35 GiB publication failed differently on each forge and the bare status codes said nothing: Gitea answered 413 from nginx, long before its own size limit, while GitHub broke on a DNS hiccup mid-transfer and showed an unreadable "000000". Upload failures now name the cause, and curl retries a transfer that dies on a transient network error.
This commit is contained in:
1 file changed
+22
-6
+22
-6
@@ -181,16 +181,33 @@ GITHUB_TOKEN="${GITHUB_TOKEN:-$(token_from_notes 'gh[pousr]_[A-Za-z0-9]{20,}|git
|
||||
success "Tokens Gitea et GitHub chargés."
|
||||
|
||||
# ─── Pré-vol des forges ──────────────────────────────────────────────────────
|
||||
CURL=(curl -sS --connect-timeout 20 --retry 2 --retry-delay 2)
|
||||
# --retry-all-errors: an ISO upload can fail on a DNS hiccup halfway through,
|
||||
# which is not in curl's default "transient" list.
|
||||
CURL=(curl -sS --connect-timeout 20 --retry 3 --retry-delay 2 --retry-all-errors)
|
||||
HTTP_CODE=""; HTTP_BODY=""
|
||||
|
||||
request() { # <outfile> <curl args…> → sets HTTP_CODE/HTTP_BODY
|
||||
request() { # <curl args…> → sets HTTP_CODE/HTTP_BODY
|
||||
local out; out="$(mktemp)"
|
||||
HTTP_CODE="$("${CURL[@]}" "$@" -o "$out" -w '%{http_code}' 2>/dev/null || echo 000)"
|
||||
# curl still prints 000 through -w when it fails, so the "|| echo 000" it
|
||||
# used to have produced a useless "000000".
|
||||
HTTP_CODE="$("${CURL[@]}" "$@" -o "$out" -w '%{http_code}' 2>/dev/null)" || HTTP_CODE="000"
|
||||
[ -n "$HTTP_CODE" ] || HTTP_CODE="000"
|
||||
HTTP_BODY="$(cat "$out")"
|
||||
rm -f "$out"
|
||||
}
|
||||
|
||||
# What a failed asset upload actually means: the two forges fail for very
|
||||
# different reasons, and neither is obvious from the bare status code.
|
||||
upload_error() { # <forge> <status>
|
||||
case "$2" in
|
||||
413) echo "$1 : 413 Request Entity Too Large — c'est le reverse proxy (nginx, client_max_body_size), pas Gitea : monte-le à 2g ou plus puis recharge nginx." ;;
|
||||
413*) echo "$1 : fichier trop gros pour le proxy (413)." ;;
|
||||
000) echo "$1 : connexion interrompue (réseau/DNS) pendant l'envoi de l'ISO — relance avec --skip-build." ;;
|
||||
401|403) echo "$1 : token sans droit d'écrire les assets (HTTP $2)." ;;
|
||||
*) echo "$1 : envoi de l'ISO refusé (HTTP $2)." ;;
|
||||
esac
|
||||
}
|
||||
|
||||
preflight_forges() {
|
||||
local perms
|
||||
|
||||
@@ -407,8 +424,7 @@ publish_gitea() {
|
||||
gitea_api POST "/releases/$release_id/assets?name=$ISO_NAME" \
|
||||
-F "attachment=@$ISO_PATH"
|
||||
[ "$HTTP_CODE" = "201" ] || [ "$HTTP_CODE" = "200" ] \
|
||||
|| { pub_err "Gitea : envoi de l'ISO refusé (HTTP $HTTP_CODE) — $(echo "$HTTP_BODY" | head -c 300)"
|
||||
pub_err "Gitea limite la taille des assets (app.ini, MAX_SIZE) : augmente-la si besoin."; return 1; }
|
||||
|| { pub_err "$(upload_error Gitea "$HTTP_CODE")"; return 1; }
|
||||
success "Gitea : ISO jointe."
|
||||
fi
|
||||
|
||||
@@ -471,7 +487,7 @@ publish_github() {
|
||||
-T "$ISO_PATH" \
|
||||
"$GH_UPLOAD/repos/$GH_REPO/releases/$release_id/assets?name=$ISO_NAME"
|
||||
[ "$HTTP_CODE" = "201" ] || [ "$HTTP_CODE" = "200" ] \
|
||||
|| { pub_err "GitHub : envoi de l'ISO refusé (HTTP $HTTP_CODE) — $(echo "$HTTP_BODY" | head -c 300)"; return 1; }
|
||||
|| { pub_err "$(upload_error GitHub "$HTTP_CODE")"; return 1; }
|
||||
success "GitHub : ISO jointe."
|
||||
fi
|
||||
|
||||
|
||||
Reference in new issue
Block a user