diff --git a/src/GenerateIndex.scala b/src/GenerateIndex.scala index 72e8188..58c574f 100644 --- a/src/GenerateIndex.scala +++ b/src/GenerateIndex.scala @@ -15,7 +15,7 @@ object GenerateIndex { val correttoIndex0 = Corretto.fullIndex(GhToken.token) val graalvmLegacyIndex0 = GraalvmLegacy.fullIndex(GhToken.token) val graalvmIndex0 = Graalvm.fullIndex(GhToken.token) - val oracleIndex0 = OracleJDKs.index() + val oracleIndex0 = Oracle.index() val adoptIndex0 = Temurin.fullIndex(GhToken.token) val zuluIndex0 = Zulu.index() val libericaIndex0 = Liberica.index() @@ -33,9 +33,9 @@ object GenerateIndex { System.err.println(s"Wrote $dest") for (((os0, arch), osArchIndex) <- index.osArchIndices.toVector.sortBy(_._1)) { - val dest0 = os.pwd / s"$baseName-$os0-$arch.json" + val dest0 = os.pwd / "indices" / s"$os0-$arch.json" val json0 = osArchIndex.json - os.write.over(dest0, json0) + os.write.over(dest0, json0, createFolders = true) System.err.println(s"Wrote $dest0") } } diff --git a/src/OracleJDKs.scala b/src/Oracle.scala similarity index 66% rename from src/OracleJDKs.scala rename to src/Oracle.scala index f9760e7..d59e2f7 100644 --- a/src/OracleJDKs.scala +++ b/src/Oracle.scala @@ -1,7 +1,7 @@ import sttp.client3.quick._ -object OracleJDKs { - final case class OracleJdkParams( +object Oracle { + final case class Params( indexOs: String, indexArch: String, indexJdkName: String, @@ -48,23 +48,25 @@ object OracleJDKs { jdk <- jdks jdkName <- jdkNames ext = if (os == "windows") "zip" else "tgz" - } yield OracleJdkParams(os, cpu, jdkName, jdk, ext) + } yield Params(os, cpu, jdkName, jdk, ext) - allParams.map(params => - val resp = quickRequest.get(params.url) - .followRedirects(false) // invalid URL => 301 + redirect to 200; keep the 301 - .response(ignore) // don't download and hang on 200s - .send(backend) + allParams + .map { params => + val resp = quickRequest.get(params.url) + .followRedirects(false) // invalid URL => 301 + redirect to 200; keep the 301 + .response(ignore) // don't download and hang on 200s + .send(backend) - if (resp.code.isSuccess) { - System.err.println(s"Valid url (status code ${resp.code}): ${params.url}") - params.index(params.url.toString) + if (resp.code.isSuccess) { + System.err.println(s"Valid url (status code ${resp.code}): ${params.url}") + params.index(params.url.toString) + } + else { + System.err.println(s"Invalid url (status code ${resp.code}): ${params.url}") + Index.empty + } } - else { - System.err.println(s"Invalid url (status code ${resp.code}): ${params.url}") - Index.empty - } - ).filterNot(_ != Index.empty) + .filterNot(_ != Index.empty) .foldLeft(Index.empty)(_ + _) }