mirror of https://github.com/stashapp/stash.git
Abort PR upload if no server is available (#922)
* gracefully abort PR upload * timeout if api doesn't respond in 15secs
This commit is contained in:
parent
8a04e5df62
commit
ccc2df7315
|
@ -5,8 +5,19 @@ uploadFile()
|
||||||
{
|
{
|
||||||
FILE=$1
|
FILE=$1
|
||||||
BASENAME="$(basename "${FILE}")"
|
BASENAME="$(basename "${FILE}")"
|
||||||
|
|
||||||
# get available server from gofile api
|
# 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
|
# 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")
|
uploadedTo=$(curl -m 120 -F "email=stash@stashapp.cc" -F "file=@$FILE" "https://$server.gofile.io/uploadFile")
|
||||||
resp=$(echo "$uploadedTo" | cut -d "\"" -f 4)
|
resp=$(echo "$uploadedTo" | cut -d "\"" -f 4)
|
||||||
|
|
Loading…
Reference in New Issue