From 189f92d7e8f9b0588ae7c0727e2ad7f6d03b0a90 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 17 Apr 2022 11:51:24 -0400 Subject: [PATCH] Show better error message when empty backup creation is attempted (closes #6941) --- .../kanade/tachiyomi/data/backup/full/FullBackupManager.kt | 5 +++++ app/src/main/res/values/strings.xml | 1 + 2 files changed, 6 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/FullBackupManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/FullBackupManager.kt index c1807cdee..f12047891 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/FullBackupManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/FullBackupManager.kt @@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.data.backup.full import android.content.Context import android.net.Uri import com.hippo.unifile.UniFile +import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.backup.AbstractBackupManager import eu.kanade.tachiyomi.data.backup.BackupConst.BACKUP_CATEGORY import eu.kanade.tachiyomi.data.backup.BackupConst.BACKUP_CATEGORY_MASK @@ -90,6 +91,10 @@ class FullBackupManager(context: Context) : AbstractBackupManager(context) { } val byteArray = parser.encodeToByteArray(BackupSerializer, backup!!) + if (byteArray.isEmpty()) { + throw IllegalStateException(context.getString(R.string.empty_backup_error)) + } + file.openOutputStream().also { // Force overwrite old file (it as? FileOutputStream)?.channel?.truncate(0) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 53d22ee6f..19fca94e6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -451,6 +451,7 @@ What do you want to backup? Creating backup Backup failed + No library entries to back up Backup/restore may not function properly if MIUI Optimization is disabled. Restore is already in progress Restoring backup