Merge pull request #12558 from t895/zip-storage-method
android: Disable compression for zip exports
This commit is contained in:
commit
d7e7a69e00
|
@ -445,7 +445,8 @@ class GamePropertiesFragment : Fragment() {
|
||||||
val zipResult = FileUtil.zipFromInternalStorage(
|
val zipResult = FileUtil.zipFromInternalStorage(
|
||||||
File(saveLocation),
|
File(saveLocation),
|
||||||
saveLocation.replaceAfterLast("/", ""),
|
saveLocation.replaceAfterLast("/", ""),
|
||||||
BufferedOutputStream(requireContext().contentResolver.openOutputStream(result))
|
BufferedOutputStream(requireContext().contentResolver.openOutputStream(result)),
|
||||||
|
compression = false
|
||||||
)
|
)
|
||||||
return@newInstance when (zipResult) {
|
return@newInstance when (zipResult) {
|
||||||
TaskState.Completed -> getString(R.string.export_success)
|
TaskState.Completed -> getString(R.string.export_success)
|
||||||
|
|
|
@ -625,7 +625,8 @@ class MainActivity : AppCompatActivity(), ThemeProvider {
|
||||||
File(DirectoryInitialization.userDirectory!!),
|
File(DirectoryInitialization.userDirectory!!),
|
||||||
DirectoryInitialization.userDirectory!!,
|
DirectoryInitialization.userDirectory!!,
|
||||||
BufferedOutputStream(contentResolver.openOutputStream(result)),
|
BufferedOutputStream(contentResolver.openOutputStream(result)),
|
||||||
taskViewModel.cancelled
|
taskViewModel.cancelled,
|
||||||
|
compression = false
|
||||||
)
|
)
|
||||||
return@newInstance when (zipResult) {
|
return@newInstance when (zipResult) {
|
||||||
TaskState.Completed -> getString(R.string.user_data_export_success)
|
TaskState.Completed -> getString(R.string.user_data_export_success)
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.yuzu.yuzu_emu.model.TaskState
|
||||||
import java.io.BufferedOutputStream
|
import java.io.BufferedOutputStream
|
||||||
import java.lang.NullPointerException
|
import java.lang.NullPointerException
|
||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
|
import java.util.zip.Deflater
|
||||||
import java.util.zip.ZipOutputStream
|
import java.util.zip.ZipOutputStream
|
||||||
import kotlin.IllegalStateException
|
import kotlin.IllegalStateException
|
||||||
|
|
||||||
|
@ -312,15 +313,23 @@ object FileUtil {
|
||||||
* @param inputFile File representation of the item that will be zipped
|
* @param inputFile File representation of the item that will be zipped
|
||||||
* @param rootDir Directory containing the inputFile
|
* @param rootDir Directory containing the inputFile
|
||||||
* @param outputStream Stream where the zip file will be output
|
* @param outputStream Stream where the zip file will be output
|
||||||
|
* @param cancelled [StateFlow] that reports whether this process has been cancelled
|
||||||
|
* @param compression Disables compression if true
|
||||||
*/
|
*/
|
||||||
fun zipFromInternalStorage(
|
fun zipFromInternalStorage(
|
||||||
inputFile: File,
|
inputFile: File,
|
||||||
rootDir: String,
|
rootDir: String,
|
||||||
outputStream: BufferedOutputStream,
|
outputStream: BufferedOutputStream,
|
||||||
cancelled: StateFlow<Boolean>? = null
|
cancelled: StateFlow<Boolean>? = null,
|
||||||
|
compression: Boolean = true
|
||||||
): TaskState {
|
): TaskState {
|
||||||
try {
|
try {
|
||||||
ZipOutputStream(outputStream).use { zos ->
|
ZipOutputStream(outputStream).use { zos ->
|
||||||
|
if (!compression) {
|
||||||
|
zos.setMethod(ZipOutputStream.DEFLATED)
|
||||||
|
zos.setLevel(Deflater.NO_COMPRESSION)
|
||||||
|
}
|
||||||
|
|
||||||
inputFile.walkTopDown().forEach { file ->
|
inputFile.walkTopDown().forEach { file ->
|
||||||
if (cancelled?.value == true) {
|
if (cancelled?.value == true) {
|
||||||
return TaskState.Cancelled
|
return TaskState.Cancelled
|
||||||
|
@ -338,6 +347,7 @@ object FileUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
Log.error("[FileUtil] Failed creating zip file - ${e.message}")
|
||||||
return TaskState.Failed
|
return TaskState.Failed
|
||||||
}
|
}
|
||||||
return TaskState.Completed
|
return TaskState.Completed
|
||||||
|
|
Loading…
Reference in a new issue