Skip to content

Commit

Permalink
Merge pull request #9 from ReviversMC/next/4.1.3
Browse files Browse the repository at this point in the history
4.1.3
  • Loading branch information
Cloudate9 authored Jun 1, 2022
2 parents e9494ff + 00efa65 commit b5873b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
5 changes: 3 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ plugins {
}

group = "com.github.reviversmc.themodindex.validation"
version = "4.1.2"
version = "4.1.3"

repositories {
mavenCentral()
maven("https://jitpack.io")
}

dependencies {
api("com.github.reviversmc:the-mod-index-api:5.1.2")
api("com.github.reviversmc:the-mod-index-api:6.0.0")
api("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.2")
}

tasks {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,27 @@ import kotlinx.coroutines.sync.Semaphore
import kotlinx.coroutines.sync.withPermit
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.SerializationException
import okhttp3.OkHttpClient
import java.io.IOException
import java.util.concurrent.atomic.AtomicInteger
import kotlin.system.exitProcess


const val COROUTINES_PER_TASK = 5 // Arbitrary number of concurrent downloads. Change if better number is found.

@ExperimentalSerializationApi
fun main(args: Array<String>) {
//TODO Validate against regex provided in json schema as well

val okHttpClient = OkHttpClient()
val apiDownloader = if (args.isEmpty()) DefaultApiDownloader(okHttpClient)
else DefaultApiDownloader(okHttpClient, args[0])
val apiDownloader = if (args.isEmpty()) DefaultApiDownloader()
else DefaultApiDownloader(baseUrl = args[0])

println("Attempting to validate index file...")

val indexJson = try {
apiDownloader.getOrDownloadIndexJson()
} catch (ex: SerializationException) {
throw SerializationException("Serialization error of \"index.json\" at repository ${apiDownloader.repositoryUrlAsString}.")
} ?: throw IOException("Could not download \"index.json\" at repository ${apiDownloader.repositoryUrlAsString}.")
throw SerializationException("Serialization error of \"index.json\" at repository ${apiDownloader.formattedBaseUrl}.")
} ?: throw IOException("Could not download \"index.json\" at repository ${apiDownloader.formattedBaseUrl}.")

val availableManifests = indexJson.identifiers.map {
if (it.lowercase() != it) throw IllegalStateException("Identifier \"$it\" is not lowercase.")
Expand Down Expand Up @@ -61,9 +60,9 @@ fun main(args: Array<String>) {
if (currentlyChecked % 10 == 0) println("Checked $currentlyChecked / ${availableManifests.size} of manifests.")

} catch (ex: SerializationException) {
throw SerializationException("Serialization error of manifest \"$it\" at repository ${apiDownloader.repositoryUrlAsString}.")
throw SerializationException("Serialization error of manifest \"$it\" at repository ${apiDownloader.formattedBaseUrl}.")
} catch (ex: IOException) {
throw IOException("Could not download manifest \"$it\" at repository ${apiDownloader.repositoryUrlAsString}.")
throw IOException("Could not download manifest \"$it\" at repository ${apiDownloader.formattedBaseUrl}.")
}
}
}
Expand Down

0 comments on commit b5873b0

Please sign in to comment.