mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-06-30 17:34:39 -05:00
Fix/extracting assets from apks (#644)
* Get rid of multiple static "assets/" usage * Correctly add new zip entry The name of the entry has to be a "/" separated path, otherwise, the files can't be found.
This commit is contained in:
@@ -213,7 +213,7 @@ object Extension {
|
|||||||
var zipEntry = zipInputStream.nextEntry
|
var zipEntry = zipInputStream.nextEntry
|
||||||
while (zipEntry != null) {
|
while (zipEntry != null) {
|
||||||
if (zipEntry.name.startsWith("assets/")) {
|
if (zipEntry.name.startsWith("assets/")) {
|
||||||
val assetFile = File(assetsFolder, zipEntry.name.substringAfter("assets/"))
|
val assetFile = File(assetsFolder, zipEntry.name)
|
||||||
assetFile.parentFile.mkdirs()
|
assetFile.parentFile.mkdirs()
|
||||||
FileOutputStream(assetFile).use { outputStream ->
|
FileOutputStream(assetFile).use { outputStream ->
|
||||||
zipInputStream.copyTo(outputStream)
|
zipInputStream.copyTo(outputStream)
|
||||||
@@ -236,7 +236,7 @@ object Extension {
|
|||||||
}
|
}
|
||||||
assetsFolder.walkTopDown().forEach { file ->
|
assetsFolder.walkTopDown().forEach { file ->
|
||||||
if (file.isFile) {
|
if (file.isFile) {
|
||||||
jarZipOutputStream.putNextEntry(ZipEntry("assets/${file.relativeTo(assetsFolder)}"))
|
jarZipOutputStream.putNextEntry(ZipEntry(file.relativeTo(assetsFolder).toString().replace("\\", "/")))
|
||||||
file.inputStream().use { inputStream ->
|
file.inputStream().use { inputStream ->
|
||||||
inputStream.copyTo(jarZipOutputStream)
|
inputStream.copyTo(jarZipOutputStream)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user