@@ -18,10 +18,11 @@ class MakeDownloadPage(version: String, releaseDate: Date = new Date()) {
18
18
import scala .sys .process ._
19
19
println(" ## fetching size of " + url)
20
20
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))
25
26
}.toOption.flatten.map { case (status, bytes) => (status, bytes match {
26
27
case meh if meh < 1024 => " "
27
28
case kilo if kilo < 1024 * 1024 => f " ${bytes.toDouble/ 1024 }%.0fK "
@@ -37,7 +38,7 @@ class MakeDownloadPage(version: String, releaseDate: Date = new Date()) {
37
38
38
39
def resourceArchive (cls : String , name : String , ext : String , desc : String ): Future [String ] = {
39
40
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"
41
42
resource(cls, fileName, desc, fullUrl, fullUrl)
42
43
}
43
44
0 commit comments