refactor(backup/creator): Reformat code

This commit is contained in:
Ahmad Ansori Palembani 2024-08-03 21:09:27 +07:00
parent 9c435891f6
commit 66ee8fb0cd
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6

View file

@ -69,8 +69,7 @@ class BackupCreator(
var file: UniFile? = null
try {
file = (
if (isAutoBackup) {
file = if (isAutoBackup) {
// Get dir of file and create
val dir = storageManager.getAutomaticBackupsDirectory()
@ -87,15 +86,13 @@ class BackupCreator(
} else {
UniFile.fromUri(context, uri)
}
)
?: throw Exception("Couldn't create backup file")
if (!file.isFile) {
if (file == null || !file.isFile) {
throw IllegalStateException("Failed to get handle on file")
}
val byteArray = parser.encodeToByteArray(Backup.serializer(), backup!!)
if (byteArray.isEmpty()) {
val byteArray = backup?.let { parser.encodeToByteArray(Backup.serializer(), it) }
if (byteArray == null || byteArray.isEmpty()) {
throw IllegalStateException(context.getString(MR.strings.empty_backup_error))
}