Skip to content

Commit 4d89c32

Browse files
authored
Fix Oracle JRE Extension Install (#670)
* Minor cleanup * Fix Oracle JRE Write issue
1 parent a76ce03 commit 4d89c32

File tree

5 files changed

+20
-42
lines changed

5 files changed

+20
-42
lines changed

server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/fileProvider/ChaptersFilesProvider.kt

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ abstract class ChaptersFilesProvider(val mangaId: Int, val chapterId: Int) : Dow
1111
abstract fun getImageImpl(index: Int): Pair<InputStream, String>
1212

1313
override fun getImage(): RetrieveFile1Args<Int> {
14-
return object : RetrieveFile1Args<Int> {
15-
override fun execute(a: Int): Pair<InputStream, String> {
16-
return getImageImpl(a)
17-
}
18-
}
14+
return RetrieveFile1Args(::getImageImpl)
1915
}
2016

2117
abstract suspend fun downloadImpl(
@@ -25,15 +21,7 @@ abstract class ChaptersFilesProvider(val mangaId: Int, val chapterId: Int) : Dow
2521
): Boolean
2622

2723
override fun download(): FileDownload3Args<DownloadChapter, CoroutineScope, suspend (DownloadChapter?, Boolean) -> Unit> {
28-
return object : FileDownload3Args<DownloadChapter, CoroutineScope, suspend (DownloadChapter?, Boolean) -> Unit> {
29-
override suspend fun execute(
30-
a: DownloadChapter,
31-
b: CoroutineScope,
32-
c: suspend (DownloadChapter?, Boolean) -> Unit
33-
): Boolean {
34-
return downloadImpl(a, b, c)
35-
}
36-
}
24+
return FileDownload3Args(::downloadImpl)
3725
}
3826

3927
abstract override fun delete(): Boolean
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
11
package suwayomi.tachidesk.manga.impl.download.fileProvider
22

3-
@FunctionalInterface
4-
interface FileDownload {
3+
fun interface FileDownload {
54
suspend fun executeDownload(vararg args: Any): Boolean
65
}
76

8-
@FunctionalInterface
9-
interface FileDownload0Args : FileDownload {
7+
fun interface FileDownload0Args : FileDownload {
108
suspend fun execute(): Boolean
119

1210
override suspend fun executeDownload(vararg args: Any): Boolean {
1311
return execute()
1412
}
1513
}
1614

17-
@FunctionalInterface
18-
interface FileDownload3Args<A, B, C> : FileDownload {
15+
fun interface FileDownload3Args<A, B, C> : FileDownload {
1916
suspend fun execute(a: A, b: B, c: C): Boolean
2017

2118
override suspend fun executeDownload(vararg args: Any): Boolean {
2219
return execute(args[0] as A, args[1] as B, args[2] as C)
2320
}
2421
}
2522

26-
@FunctionalInterface
27-
interface FileDownloader {
23+
fun interface FileDownloader {
2824
fun download(): FileDownload
2925
}

server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/fileProvider/FileRetriever.kt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,26 @@ package suwayomi.tachidesk.manga.impl.download.fileProvider
22

33
import java.io.InputStream
44

5-
@FunctionalInterface
6-
interface RetrieveFile {
5+
fun interface RetrieveFile {
76
fun executeGetImage(vararg args: Any): Pair<InputStream, String>
87
}
98

10-
@FunctionalInterface
11-
interface RetrieveFile0Args : RetrieveFile {
9+
fun interface RetrieveFile0Args : RetrieveFile {
1210
fun execute(): Pair<InputStream, String>
1311

1412
override fun executeGetImage(vararg args: Any): Pair<InputStream, String> {
1513
return execute()
1614
}
1715
}
1816

19-
@FunctionalInterface
20-
interface RetrieveFile1Args<A> : RetrieveFile {
17+
fun interface RetrieveFile1Args<A> : RetrieveFile {
2118
fun execute(a: A): Pair<InputStream, String>
2219

2320
override fun executeGetImage(vararg args: Any): Pair<InputStream, String> {
2421
return execute(args[0] as A)
2522
}
2623
}
2724

28-
@FunctionalInterface
29-
interface FileRetriever {
25+
fun interface FileRetriever {
3026
fun getImage(): RetrieveFile
3127
}

server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/fileProvider/impl/ThumbnailFileProvider.kt

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,10 @@ class ThumbnailFileProvider(val mangaId: Int) : DownloadedFilesProvider {
3737
}
3838

3939
override fun getImage(): RetrieveFile0Args {
40-
return object : RetrieveFile0Args {
41-
override fun execute(): Pair<InputStream, String> {
42-
return getImageImpl()
43-
}
44-
}
40+
return RetrieveFile0Args(::getImageImpl)
4541
}
4642

47-
suspend fun downloadImpl(): Boolean {
43+
private suspend fun downloadImpl(): Boolean {
4844
val isExistingFile = getFilePath() != null
4945
if (isExistingFile) {
5046
return true
@@ -60,11 +56,7 @@ class ThumbnailFileProvider(val mangaId: Int) : DownloadedFilesProvider {
6056
}
6157

6258
override fun download(): FileDownload0Args {
63-
return object : FileDownload0Args {
64-
override suspend fun execute(): Boolean {
65-
return downloadImpl()
66-
}
67-
}
59+
return FileDownload0Args(::downloadImpl)
6860
}
6961

7062
override fun delete(): Boolean {

server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/BytecodeEditor.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import org.objectweb.asm.Opcodes
1818
import java.nio.file.FileSystems
1919
import java.nio.file.Files
2020
import java.nio.file.Path
21+
import java.nio.file.StandardOpenOption
2122
import kotlin.streams.asSequence
2223

2324
object BytecodeEditor {
@@ -257,6 +258,11 @@ object BytecodeEditor {
257258
}
258259

259260
private fun write(pair: Pair<Path, ByteArray>) {
260-
Files.write(pair.first, pair.second)
261+
Files.write(
262+
pair.first,
263+
pair.second,
264+
StandardOpenOption.CREATE,
265+
StandardOpenOption.TRUNCATE_EXISTING
266+
)
261267
}
262268
}

0 commit comments

Comments
 (0)