From ccc2df73158572c1631a1d656c55320330c7bd4d Mon Sep 17 00:00:00 2001 From: bnkai <48220860+bnkai@users.noreply.github.com> Date: Fri, 6 Nov 2020 04:15:50 +0200 Subject: [PATCH] Abort PR upload if no server is available (#922) * gracefully abort PR upload * timeout if api doesn't respond in 15secs --- scripts/upload-pull-request.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/upload-pull-request.sh b/scripts/upload-pull-request.sh index e4d0214d3..10523c903 100644 --- a/scripts/upload-pull-request.sh +++ b/scripts/upload-pull-request.sh @@ -5,8 +5,19 @@ uploadFile() { FILE=$1 BASENAME="$(basename "${FILE}")" + # get available server from gofile api - server=$(curl https://apiv2.gofile.io/getServer |cut -d "," -f 2 | cut -d "\"" -f 6) + serverApi=$(curl -m 15 https://apiv2.gofile.io/getServer) + resp=$(echo "$serverApi" | cut -d "\"" -f 4) + + # if no server is available abort + if [ $resp != "ok" ] ; then + echo "Upload of $BASENAME failed! Server not available." + echo + return + fi + server=$(echo "$serverApi" | cut -d "," -f 2 | cut -d "\"" -f 6) + # abort if it takes more than two minutes to upload uploadedTo=$(curl -m 120 -F "email=stash@stashapp.cc" -F "file=@$FILE" "https://$server.gofile.io/uploadFile") resp=$(echo "$uploadedTo" | cut -d "\"" -f 4)