Make this configurable
This commit is contained in:
parent
697b9e0bec
commit
6a6fdd5471
2 changed files with 9 additions and 6 deletions
|
@ -62,7 +62,8 @@ class BackupWorker @AssistedInject constructor(
|
|||
PathTools.compressDocumentFileDirectory(
|
||||
contentResolver = applicationContext.contentResolver,
|
||||
source = world.getOrThrow().documentFile!!,
|
||||
target = it
|
||||
target = it,
|
||||
inflate = true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,12 +13,13 @@ class PathTools {
|
|||
fun compressDocumentFileDirectory(
|
||||
contentResolver: ContentResolver,
|
||||
source: DocumentFile,
|
||||
target: OutputStream
|
||||
target: OutputStream,
|
||||
inflate: Boolean = false
|
||||
) {
|
||||
target.use {
|
||||
ZstdCompressorOutputStream(it).use {
|
||||
TarArchiveOutputStream(it).use { outputStream ->
|
||||
compressInner(contentResolver, source, outputStream)
|
||||
compressInner(contentResolver, source, outputStream, "", inflate)
|
||||
outputStream.finish()
|
||||
}
|
||||
}
|
||||
|
@ -29,14 +30,15 @@ class PathTools {
|
|||
contentResolver: ContentResolver,
|
||||
source: DocumentFile,
|
||||
archiveOutputStream: TarArchiveOutputStream,
|
||||
prefix: String = ""
|
||||
prefix: String = "",
|
||||
inflate: Boolean = false,
|
||||
) {
|
||||
source.listFiles().forEach {
|
||||
if (!it.isDirectory) {
|
||||
val entry = TarArchiveEntry(prefix + it.name)
|
||||
entry.setModTime(it.lastModified())
|
||||
|
||||
val inflate = it.name!!.endsWith(".mca")
|
||||
val inflate = inflate and it.name!!.endsWith(".mca")
|
||||
|
||||
if (inflate) {
|
||||
contentResolver.openInputStream(it.uri)!!.use { inputStream ->
|
||||
|
@ -66,7 +68,7 @@ class PathTools {
|
|||
archiveOutputStream.putArchiveEntry(entry)
|
||||
archiveOutputStream.closeArchiveEntry() // Close directory entry immediately (no content)
|
||||
|
||||
compressInner(contentResolver, it, archiveOutputStream, prefix + it.name + "/")
|
||||
compressInner(contentResolver, it, archiveOutputStream, prefix + it.name + "/", inflate)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue