This commit is contained in:
bskjon 2024-04-11 18:25:45 +02:00
parent 5eb94df884
commit 72e73c2c20

View File

@ -54,10 +54,15 @@ class DownloadAndStoreCoverTask(@Autowired override var coordinator: Coordinator
client.getOutFile()
}
val coversInDifferentFormats = outDir.listFiles { it -> it.isFile && it.extension.lowercase() in client.contentTypeToExtension().values } ?: emptyArray()
var message: String? = null
val result = if (outFile?.exists() == true) {
message = "${outFile.name} already exists"
outFile
} else if (coversInDifferentFormats.isNotEmpty()) {
coversInDifferentFormats.random()
} else if (outFile != null) {
runBlocking {
client.download(outFile)