mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
refactor(backup/creator): Reformat code
This commit is contained in:
parent
9c435891f6
commit
66ee8fb0cd
1 changed files with 18 additions and 21 deletions
|
@ -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))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue