Skip to content

Commit

Permalink
make all properties optional, which allows compatibility with older b…
Browse files Browse the repository at this point in the history
…ackups (e.g. when it was without media, or without iv)
  • Loading branch information
hg42 authored and machiav3lli committed Jan 10, 2025
1 parent 62aa8cc commit 888820b
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions app/src/main/java/com/machiav3lli/backup/items/BackupProperties.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ open class BackupProperties : AppMetaInfo, Parcelable {
@Serializable(with = LocalDateTimeSerializer::class)
var backupDate: LocalDateTime? = null
private set
val hasApk: Boolean
val hasAppData: Boolean
val hasDevicesProtectedData: Boolean
val hasExternalData: Boolean
val hasObbData: Boolean
val hasMediaData: Boolean
var hasApk: Boolean = false
var hasAppData: Boolean = false
var hasDevicesProtectedData: Boolean = false
var hasExternalData: Boolean = false
var hasObbData: Boolean = false
var hasMediaData: Boolean = false
var cipherType: String? = null
val iv: ByteArray?
val cpuArch: String?
var iv: ByteArray? = null
var cpuArch: String? = null

fun getBackupDir(appBackupDir: StorageFile?): StorageFile? =
appBackupDir?.findFile(backupFolderName)
Expand Down Expand Up @@ -141,8 +141,9 @@ open class BackupProperties : AppMetaInfo, Parcelable {
hasObbData = source.readByte().toInt() != 0
hasMediaData = source.readByte().toInt() != 0
cipherType = source.readString()
iv = ByteArray(Cipher.getInstance(cipherType).blockSize)
source.readByteArray(iv)
iv = ByteArray(Cipher.getInstance(cipherType).blockSize).also {
source.readByteArray(it)
}
cpuArch = source.readString()
}

Expand Down

0 comments on commit 888820b

Please sign in to comment.