Handle archives with nested directories properly
Closes #9389 (cherry picked from commit 20bec66a9de5ae34dd437714ff5f80801e2e92b8)
This commit is contained in:
parent
72a20eca12
commit
4ade0b3ed4
@ -26,9 +26,11 @@ internal class RarPageLoader(file: File) : PageLoader() {
|
|||||||
rar.fileHeaders.asSequence()
|
rar.fileHeaders.asSequence()
|
||||||
.filterNot { it.isDirectory }
|
.filterNot { it.isDirectory }
|
||||||
.forEach { header ->
|
.forEach { header ->
|
||||||
val pageFile = File(tmpDir, header.fileName).also { it.createNewFile() }
|
val pageOutputStream = File(tmpDir, header.fileName.substringAfterLast("/"))
|
||||||
|
.also { it.createNewFile() }
|
||||||
|
.outputStream()
|
||||||
getStream(rar, header).use {
|
getStream(rar, header).use {
|
||||||
it.copyTo(pageFile.outputStream())
|
it.copyTo(pageOutputStream)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,8 @@ internal class ZipPageLoader(
|
|||||||
generateSequence { zipInputStream.nextEntry }
|
generateSequence { zipInputStream.nextEntry }
|
||||||
.filterNot { it.isDirectory }
|
.filterNot { it.isDirectory }
|
||||||
.forEach { entry ->
|
.forEach { entry ->
|
||||||
File(tmpDir, entry.name).also { it.createNewFile() }
|
File(tmpDir, entry.name.substringAfterLast("/"))
|
||||||
|
.also { it.createNewFile() }
|
||||||
.outputStream().use { pageOutputStream ->
|
.outputStream().use { pageOutputStream ->
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
pageOutputStream.write(zipInputStream.readNBytes(entry.size.toInt()))
|
pageOutputStream.write(zipInputStream.readNBytes(entry.size.toInt()))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user