also actually allow overwriting the cache if necessary
All checks were successful
Publish to snapshot maven / build (push) Successful in 26s
All checks were successful
Publish to snapshot maven / build (push) Successful in 26s
This commit is contained in:
parent
44217c379f
commit
c4be767566
|
@ -7,7 +7,7 @@ plugins {
|
|||
}
|
||||
|
||||
group = "dev.frogmc"
|
||||
version = "0.0.1-alpha.7"
|
||||
version = "0.0.1-alpha.8"
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
|
|
|
@ -49,7 +49,7 @@ object VersionChecker {
|
|||
}
|
||||
|
||||
fun validateVersion(version: String, ignoreCache: Boolean = false, offlineMode: Boolean): Boolean {
|
||||
if (validVersions.isEmpty()) getValidVersions(ignoreCache)
|
||||
if (validVersions.isEmpty() || ignoreCache) getValidVersions(ignoreCache)
|
||||
if (!validVersions.any { it.id == version }) {
|
||||
if (!offlineMode) {
|
||||
return validateVersion(version, ignoreCache = true, offlineMode = false)
|
||||
|
@ -97,7 +97,7 @@ object VersionChecker {
|
|||
}
|
||||
|
||||
private fun getValidVersions(ignoreCache: Boolean = false) {
|
||||
if (validVersions.isNotEmpty()) return
|
||||
if (validVersions.isNotEmpty() && !ignoreCache) return
|
||||
// get json from https://piston-meta.mojang.com/mc/game/version_manifest_v2.json
|
||||
// make http request
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.net.URI
|
|||
import java.nio.charset.StandardCharsets
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.StandardCopyOption
|
||||
import java.util.stream.Collectors
|
||||
import kotlin.io.path.createParentDirectories
|
||||
import kotlin.io.path.inputStream
|
||||
|
@ -16,7 +17,7 @@ object CachingHttpClient {
|
|||
fun downloadTo(uri: URI, path: Path, allowOverwrite: Boolean) {
|
||||
if (allowOverwrite || path.notExists()) {
|
||||
path.createParentDirectories()
|
||||
Files.copy(getUncached(uri), path)
|
||||
Files.copy(getUncached(uri), path, StandardCopyOption.REPLACE_EXISTING)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +25,7 @@ object CachingHttpClient {
|
|||
val cache = getCacheFile(uri)
|
||||
if (ignoreCache || cache.notExists()) {
|
||||
getUncached(uri).use {
|
||||
Files.copy(it, cache)
|
||||
Files.copy(it, cache, StandardCopyOption.REPLACE_EXISTING)
|
||||
}
|
||||
}
|
||||
return cache.inputStream()
|
||||
|
|
Loading…
Reference in a new issue