Address CR

This commit is contained in:
Dude so hot authored and renovate[bot] committed 2024-10-15 19:08:12 +08:00
1 parent aaea83b932
commit ac23a4312d
1 file changed
+3 -3
@@ -77,7 +77,7 @@ class SpiderDen(val info: GalleryInfo) {
// Search in both directories to maintain compatibility
private val fileCache by lazy {
listOf(tempDownloadDir, downloadDir).mapNotNull { it?.list() }.flatten().associateBy { it.name } as MutableMap
listOfNotNull(tempDownloadDir, downloadDir).map(Path::list).flatten().associateBy { it.name } as MutableMap
}
private val imageDir
@@ -159,9 +159,9 @@ class SpiderDen(val info: GalleryInfo) {
removeTempFile(index)
}
private fun Path.findDownloadFileForIndex(index: Int, extension: String): Path {
private fun Path.findDownloadFileForIndex(index: Int, extension: String) = with(lock) {
val name = perFilename(index, extension)
return lock.write { fileCache.getOrPut(name) { resolve(name) } }
read { fileCache[name] } ?: resolve(name).also { write { fileCache[name] = it } }
}
suspend fun makeHttpCallAndSaveImage(