Skip to content

Commit

Permalink
Fix Oracle JRE Extension Install (#670)
Browse files Browse the repository at this point in the history
* Minor cleanup

* Fix Oracle JRE Write issue
  • Loading branch information
Syer10 authored Aug 28, 2023
1 parent a76ce03 commit 4d89c32
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
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 {
return execute()
}
}

@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 {
return execute(args[0] as A, args[1] as B, args[2] as C)
}
}

@FunctionalInterface
interface FileDownloader {
fun interface FileDownloader {
fun download(): FileDownload
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,26 @@ 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> {
return execute()
}
}

@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> {
return execute(args[0] as A)
}
}

@FunctionalInterface
interface FileRetriever {
fun interface FileRetriever {
fun getImage(): RetrieveFile
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
)
}
}

0 comments on commit 4d89c32

Please sign in to comment.