mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-26 19:08:25 +01:00
Reappear stably on the api30 Android Studio Emulator, first save a large backup file, then save a small backup file, overwriting the previous larger backup file, so you get a backup file with a larger size but only the first part is meaningful,
This commit is contained in:
parent
90214d02d7
commit
6f5328f663
@ -32,6 +32,7 @@ import logcat.LogPriority
|
||||
import okio.buffer
|
||||
import okio.gzip
|
||||
import okio.sink
|
||||
import java.io.FileOutputStream
|
||||
import kotlin.math.max
|
||||
|
||||
class FullBackupManager(context: Context) : AbstractBackupManager(context) {
|
||||
@ -85,7 +86,10 @@ class FullBackupManager(context: Context) : AbstractBackupManager(context) {
|
||||
?: throw Exception("Couldn't create backup file")
|
||||
|
||||
val byteArray = parser.encodeToByteArray(BackupSerializer, backup!!)
|
||||
file.openOutputStream().sink().gzip().buffer().use { it.write(byteArray) }
|
||||
file.openOutputStream().also {
|
||||
// Force overwrite old file size,
|
||||
(it as? FileOutputStream)?.channel?.truncate(0)
|
||||
}.sink().gzip().buffer().use { it.write(byteArray) }
|
||||
val fileUri = file.uri
|
||||
|
||||
// Make sure it's a valid backup file
|
||||
|
Loading…
Reference in New Issue
Block a user