From af209d7048c35f911d4da9bd82e13418750c924e Mon Sep 17 00:00:00 2001 From: Koitharu Date: Sun, 13 Oct 2024 18:24:48 +0300 Subject: [PATCH] Fix external plugin communication (cherry picked from commit 2214c207425b820ae3d575d7f55f6fb0943df7f0) --- .../core/parser/external/ExternalPluginContentSource.kt | 2 +- .../main/kotlin/org/koitharu/kotatsu/core/util/ext/File.kt | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/parser/external/ExternalPluginContentSource.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/parser/external/ExternalPluginContentSource.kt index 103b40d66..bc7280336 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/parser/external/ExternalPluginContentSource.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/parser/external/ExternalPluginContentSource.kt @@ -141,7 +141,7 @@ class ExternalPluginContentSource( @Blocking @WorkerThread fun getPageUrl(url: String): String { - val uri = "content://${source.authority}/pages/0".toUri().buildUpon() + val uri = "content://${source.authority}/manga/pages/0".toUri().buildUpon() .appendQueryParameter("url", url) .build() return contentResolver.query(uri, null, null, null, null) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/File.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/File.kt index 174b0715c..a653d40c9 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/File.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/File.kt @@ -10,12 +10,11 @@ import android.provider.OpenableColumns import androidx.core.database.getStringOrNull import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.runInterruptible -import okhttp3.internal.closeQuietly import org.jetbrains.annotations.Blocking import org.koitharu.kotatsu.R import org.koitharu.kotatsu.core.fs.FileSequence +import java.io.BufferedReader import java.io.File -import java.io.InputStream import java.nio.file.attribute.BasicFileAttributes import java.util.zip.ZipEntry import java.util.zip.ZipFile @@ -35,8 +34,8 @@ fun File.takeIfWriteable() = takeIf { it.exists() && it.canWrite() } fun File.isNotEmpty() = length() != 0L @Blocking -fun ZipFile.readText(entry: ZipEntry) = getInputStream(entry).bufferedReader().use { - it.readText() +fun ZipFile.readText(entry: ZipEntry) = getInputStream(entry).use { output -> + output.bufferedReader().use(BufferedReader::readText) } fun File.getStorageName(context: Context): String = runCatching {