This commit is contained in:
carbotaniuman 2020-08-07 18:20:39 -05:00
parent 13b80cf02f
commit 3dc6a5d8ae
2 changed files with 44 additions and 2 deletions

View file

@ -77,3 +77,41 @@ tasks.register("generateVersion", Copy) {
} }
sourceSets.main.java.srcDir generateVersion.outputs.files sourceSets.main.java.srcDir generateVersion.outputs.files
tasks.register("depsize") {
description = 'Prints dependencies for "default" configuration'
doLast() {
listConfigurationDependencies(configurations.default)
}
}
tasks.register("depsize-all-configurations") {
description = 'Prints dependencies for all available configurations'
doLast() {
configurations
.findAll { it.isCanBeResolved() }
.each { listConfigurationDependencies(it) }
}
}
def listConfigurationDependencies(Configuration configuration) {
def formatStr = "%,10.2f"
def size = configuration.collect { it.length() / (1024 * 1024) }.sum()
def out = new StringBuffer()
out << "\nConfiguration name: \"${configuration.name}\"\n"
if (size) {
out << 'Total dependencies size:'.padRight(65)
out << "${String.format(formatStr, size)} Mb\n\n"
configuration.sort { -it.length() }
.each {
out << "${it.name}".padRight(65)
out << "${String.format(formatStr, (it.length() / 1024))} kb\n"
}
} else {
out << 'No dependencies found';
}
println(out)
}

View file

@ -116,7 +116,11 @@ class MangaDexClient(private val clientSettingsFile: String) {
clientSettings.maxCacheSizeInMebibytes * 1024 * 1024 /* MiB to bytes */ clientSettings.maxCacheSizeInMebibytes * 1024 * 1024 /* MiB to bytes */
) )
cache.get("statistics")?.use { cache.get("statistics")?.use {
try {
statistics.set(JACKSON.readValue<Statistics>(it.getInputStream(0))) statistics.set(JACKSON.readValue<Statistics>(it.getInputStream(0)))
} catch (_: JsonProcessingException) {
cache.remove("statistics")
}
} }
} catch (e: HeaderMismatchException) { } catch (e: HeaderMismatchException) {
LOGGER.warn { "Cache version may be outdated - remove if necessary" } LOGGER.warn { "Cache version may be outdated - remove if necessary" }
@ -479,7 +483,7 @@ class MangaDexClient(private val clientSettingsFile: String) {
} }
private fun isSecretValid(clientSecret: String): Boolean { private fun isSecretValid(clientSecret: String): Boolean {
return Pattern.matches("^[a-zA-Z0-9]{$CLIENT_KEY_LENGTH}$", clientSecret) return Pattern.matches("^[a-zA-Z0-9]*$CLIENT_KEY_LENGTH}$", clientSecret)
} }
companion object { companion object {