Skip to content

Commit 750b5ff

Browse files
authored
Merge pull request #486 from lrytz/2.12.x
Change download URL to GitHub
2 parents 271e2d5 + 4092808 commit 750b5ff

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main/scala/MakeDownloadPage.scala

+6-5
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ class MakeDownloadPage(version: String, releaseDate: Date = new Date()) {
1818
import scala.sys.process._
1919
println("## fetching size of "+ url)
2020
scala.util.Try {
21-
val responseHeader = Process(s"curl -m 5 --silent -D - -X HEAD $url").lineStream
22-
val contentLength = responseHeader.find(_.toLowerCase.startsWith("content-length"))
23-
val bytes = contentLength.map(_.split(":",2)(1).trim.toInt)
24-
bytes map (b => (responseHeader.head, b))
21+
val responseHeader = Process(s"curl -L -m 15 --silent -D - -X HEAD $url").lineStream
22+
val contentLength = responseHeader.filter(_.toLowerCase.startsWith("content-length"))
23+
// max handles redirects. no maxOption on 2.12, but we have a surrounding Try
24+
val bytes = contentLength.map(_.split(":",2)(1).trim.toInt).max
25+
Some(bytes) map (b => (responseHeader.head, b))
2526
}.toOption.flatten.map { case (status, bytes) => (status, bytes match {
2627
case meh if meh < 1024 => ""
2728
case kilo if kilo < 1024*1024 => f"${bytes.toDouble/1024}%.0fK"
@@ -37,7 +38,7 @@ class MakeDownloadPage(version: String, releaseDate: Date = new Date()) {
3738

3839
def resourceArchive(cls: String, name: String, ext: String, desc: String): Future[String] = {
3940
val fileName = s"$name-$version.$ext"
40-
val fullUrl = s"https://downloads.lightbend.com/scala/$version/$fileName"
41+
val fullUrl = s"https://github.com/scala/scala/releases/download/v$version/$fileName"
4142
resource(cls, fileName, desc, fullUrl, fullUrl)
4243
}
4344

0 commit comments

Comments
 (0)