@@ -76,35 +76,48 @@ function downloadSpigot {
76
76
fi
77
77
78
78
setServerVar
79
+ curlArgs=()
79
80
if [ -f " $SERVER " ] && ! isTrue " $FORCE_REDOWNLOAD " ; then
80
81
# tell curl to only download when newer
81
- curlArgs= " -z $SERVER "
82
+ curlArgs+=( -z " $SERVER " )
82
83
fi
83
84
if isDebugging; then
84
- curlArgs= " $curlArgs -v "
85
+ curlArgs+=(-v)
85
86
fi
86
87
log " Downloading $match from $downloadUrl ..."
87
- curl -fsSL -o " $SERVER " $curlArgs " $downloadUrl "
88
- if [[ $? != 0 || $( grep -c " DOCTYPE html" " $SERVER " ) != 0 ]]; then
88
+
89
+ tempFile=" $SERVER .$$ "
90
+
91
+ # HTTP error or download site responded with an HTML error page
92
+ if ! curl -fsSL -o " $tempFile " " ${curlArgs[@]} " " $downloadUrl " || grep -iq " doctype html" " $tempFile " ; then
93
+
89
94
cat << EOF
90
95
91
96
ERROR: failed to download from $downloadUrl
92
97
Visit https://getbukkit.org/download/${getbukkitFlavor} to lookup the
93
- exact version, such as 1.4.6-R0.4-SNAPSHOT or 1.8-R0.1-SNAPSHOT-latest.
94
- Click into the version entry to find the **exact** version, because something
95
- like "1.8" is not sufficient according to their download naming.
98
+ exact version or see if download site is unavailable.
99
+ Click into the version entry to find the **exact** version.
96
100
97
101
EOF
98
102
99
- if isDebugging && [[ $( grep -c " DOCTYPE html" " $SERVER " ) != 0 ]]; then
100
- cat " $SERVER "
103
+ if isDebugging && grep -iq " doctype html" " $tempFile " ; then
104
+ cat " $tempFile "
105
+ fi
106
+
107
+ if [ -f " $SERVER " ]; then
108
+ log " Continuing with existing $SERVER file"
109
+ else
110
+ # remove invalid download
111
+ rm " $tempFile "
112
+ exit 3
101
113
fi
102
114
103
- # remove invalid download
104
- rm " $SERVER "
105
- exit 3
115
+ else
116
+ mv " $tempFile " " $SERVER "
117
+
106
118
fi
107
119
120
+
108
121
JVM_OPTS=" ${JVM_OPTS} -DIReallyKnowWhatIAmDoingISwear"
109
122
export JVM_OPTS
110
123
}
0 commit comments