Skip to content

Commit

Permalink
Merge pull request apache#454 from jey/atomic-sbt-download. Closes ap…
Browse files Browse the repository at this point in the history
…ache#454.

Make sbt download an atomic operation

Modifies the `sbt/sbt` script to gracefully recover when a previous invocation died in the middle of downloading the SBT jar.

Author: Jey Kottalam <jey@cs.berkeley.edu>

== Merge branch commits ==

commit 6c600eb434a2f3e7d70b67831aeebde9b5c0f43b
Author: Jey Kottalam <jey@cs.berkeley.edu>
Date:   Fri Jan 17 10:43:54 2014 -0800

    Make sbt download an atomic operation
  • Loading branch information
jey authored and pwendell committed Feb 8, 2014
1 parent fabf174 commit 7805080
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sbt/sbt
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ JAR=sbt/sbt-launch-${SBT_VERSION}.jar
if [ ! -f ${JAR} ]; then
# Download
printf "Attempting to fetch sbt\n"
JAR_DL=${JAR}.part
if hash curl 2>/dev/null; then
curl --progress-bar ${URL1} > ${JAR} || curl --progress-bar ${URL2} > ${JAR}
(curl --progress-bar ${URL1} > ${JAR_DL} || curl --progress-bar ${URL2} > ${JAR_DL}) && mv ${JAR_DL} ${JAR}
elif hash wget 2>/dev/null; then
wget --progress=bar ${URL1} -O ${JAR} || wget --progress=bar ${URL2} -O ${JAR}
(wget --progress=bar ${URL1} -O ${JAR_DL} || wget --progress=bar ${URL2} -O ${JAR_DL}) && mv ${JAR_DL} ${JAR}
else
printf "You do not have curl or wget installed, please install sbt manually from http://www.scala-sbt.org/\n"
exit -1
Expand Down

0 comments on commit 7805080

Please sign in to comment.