Fix Oracle JRE Extension Install (#670)

* Minor cleanup

* Fix Oracle JRE Write issue
This commit is contained in:
Mitchell Syer
2023-08-27 22:39:05 -04:00
committed by GitHub
parent a76ce03911
commit 4d89c324b9
5 changed files with 20 additions and 42 deletions
@@ -11,11 +11,7 @@ abstract class ChaptersFilesProvider(val mangaId: Int, val chapterId: Int) : Dow
abstract fun getImageImpl(index: Int): Pair<InputStream, String>
override fun getImage(): RetrieveFile1Args<Int> {
return object : RetrieveFile1Args<Int> {
override fun execute(a: Int): Pair<InputStream, String> {
return getImageImpl(a)
}
}
return RetrieveFile1Args(::getImageImpl)
}
abstract suspend fun downloadImpl(
@@ -25,15 +21,7 @@ abstract class ChaptersFilesProvider(val mangaId: Int, val chapterId: Int) : Dow
): Boolean
override fun download(): FileDownload3Args<DownloadChapter, CoroutineScope, suspend (DownloadChapter?, Boolean) -> Unit> {
return object : FileDownload3Args<DownloadChapter, CoroutineScope, suspend (DownloadChapter?, Boolean) -> Unit> {
override suspend fun execute(
a: DownloadChapter,
b: CoroutineScope,
c: suspend (DownloadChapter?, Boolean) -> Unit
): Boolean {
return downloadImpl(a, b, c)
}
}
return FileDownload3Args(::downloadImpl)
}
abstract override fun delete(): Boolean
@@ -1,12 +1,10 @@
package suwayomi.tachidesk.manga.impl.download.fileProvider
@FunctionalInterface
interface FileDownload {
fun interface FileDownload {
suspend fun executeDownload(vararg args: Any): Boolean
}
@FunctionalInterface
interface FileDownload0Args : FileDownload {
fun interface FileDownload0Args : FileDownload {
suspend fun execute(): Boolean
override suspend fun executeDownload(vararg args: Any): Boolean {
@@ -14,8 +12,7 @@ interface FileDownload0Args : FileDownload {
}
}
@FunctionalInterface
interface FileDownload3Args<A, B, C> : FileDownload {
fun interface FileDownload3Args<A, B, C> : FileDownload {
suspend fun execute(a: A, b: B, c: C): Boolean
override suspend fun executeDownload(vararg args: Any): Boolean {
@@ -23,7 +20,6 @@ interface FileDownload3Args<A, B, C> : FileDownload {
}
}
@FunctionalInterface
interface FileDownloader {
fun interface FileDownloader {
fun download(): FileDownload
}
@@ -2,13 +2,11 @@ package suwayomi.tachidesk.manga.impl.download.fileProvider
import java.io.InputStream
@FunctionalInterface
interface RetrieveFile {
fun interface RetrieveFile {
fun executeGetImage(vararg args: Any): Pair<InputStream, String>
}
@FunctionalInterface
interface RetrieveFile0Args : RetrieveFile {
fun interface RetrieveFile0Args : RetrieveFile {
fun execute(): Pair<InputStream, String>
override fun executeGetImage(vararg args: Any): Pair<InputStream, String> {
@@ -16,8 +14,7 @@ interface RetrieveFile0Args : RetrieveFile {
}
}
@FunctionalInterface
interface RetrieveFile1Args<A> : RetrieveFile {
fun interface RetrieveFile1Args<A> : RetrieveFile {
fun execute(a: A): Pair<InputStream, String>
override fun executeGetImage(vararg args: Any): Pair<InputStream, String> {
@@ -25,7 +22,6 @@ interface RetrieveFile1Args<A> : RetrieveFile {
}
}
@FunctionalInterface
interface FileRetriever {
fun interface FileRetriever {
fun getImage(): RetrieveFile
}
@@ -37,14 +37,10 @@ class ThumbnailFileProvider(val mangaId: Int) : DownloadedFilesProvider {
}
override fun getImage(): RetrieveFile0Args {
return object : RetrieveFile0Args {
override fun execute(): Pair<InputStream, String> {
return getImageImpl()
}
}
return RetrieveFile0Args(::getImageImpl)
}
suspend fun downloadImpl(): Boolean {
private suspend fun downloadImpl(): Boolean {
val isExistingFile = getFilePath() != null
if (isExistingFile) {
return true
@@ -60,11 +56,7 @@ class ThumbnailFileProvider(val mangaId: Int) : DownloadedFilesProvider {
}
override fun download(): FileDownload0Args {
return object : FileDownload0Args {
override suspend fun execute(): Boolean {
return downloadImpl()
}
}
return FileDownload0Args(::downloadImpl)
}
override fun delete(): Boolean {
@@ -18,6 +18,7 @@ import org.objectweb.asm.Opcodes
import java.nio.file.FileSystems
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.StandardOpenOption
import kotlin.streams.asSequence
object BytecodeEditor {
@@ -257,6 +258,11 @@ object BytecodeEditor {
}
private fun write(pair: Pair<Path, ByteArray>) {
Files.write(pair.first, pair.second)
Files.write(
pair.first,
pair.second,
StandardOpenOption.CREATE,
StandardOpenOption.TRUNCATE_EXISTING
)
}
}