Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Oracle JRE Extension Install #670

Merged
merged 2 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
)
}
}