diff --git a/server/build.gradle.kts b/server/build.gradle.kts index dda27f4..271d75d 100644 --- a/server/build.gradle.kts +++ b/server/build.gradle.kts @@ -59,7 +59,7 @@ sourceSets { } // should be bumped with each stable release -val inspectorVersion = "v0.5.1" +val inspectorVersion = "v0.6.0" // counts commit count on master val inspectorRevision = runCatching { @@ -108,7 +108,8 @@ tasks { freeCompilerArgs = listOf( "-Xopt-in=kotlin.RequiresOptIn", "-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", - "-Xopt-in=kotlinx.coroutines.InternalCoroutinesApi" + "-Xopt-in=kotlinx.coroutines.InternalCoroutinesApi", + "-Xopt-in=kotlin.io.path.ExperimentalPathApi", ) } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/InspectorMain.kt b/server/src/main/kotlin/suwayomi/tachidesk/InspectorMain.kt index 488d272..9ff633f 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/InspectorMain.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/InspectorMain.kt @@ -14,8 +14,13 @@ import kotlinx.serialization.json.Json import mu.KotlinLogging import suwayomi.tachidesk.manga.impl.extension.Extension.installAPK import java.io.File +import java.nio.file.Files +import java.nio.file.Paths +import kotlin.io.path.extension +import kotlin.streams.toList object InspectorMain { + private val logger = KotlinLogging.logger {} suspend fun inspectorMain(args: Array) { @@ -28,16 +33,15 @@ object InspectorMain { val tmpDirPath = args[2] val tmpDir = File(tmpDirPath, "tmp").also { it.mkdir() } - val extensions = File(apksPath).listFiles().orEmpty().mapNotNull { - if (it.extension == "apk") { - logger.info("Installing ${it.absolutePath}") - - val (pkgName, sources) = installAPK(tmpDir) { - it - } + val extensions = Files.find(Paths.get(apksPath), 2, { _, fileAttributes -> fileAttributes.isRegularFile }) + .filter { it.extension == "apk" } + .toList() + .map { + logger.info("Installing $it") + val (pkgName, sources) = installAPK(tmpDir) { it.toFile() } pkgName to sources.map { source -> SourceJson(source) } - } else null - }.toMap() + } + .toMap() File(outputPath).writeText(Json.encodeToString(extensions)) }