From 11c01235ac32c8fd3de864c37cab82367b4a9e41 Mon Sep 17 00:00:00 2001 From: nicki <72807749+curche@users.noreply.github.com> Date: Mon, 9 May 2022 20:33:40 +0530 Subject: [PATCH] Don't save categories in backup if not selected (#7101) Currently, manually created backups contain list of categories even if Categories option is not selected during Backup Prompt. This leads to empty categories being created when restoring such backup files This commit adds a check before saving categories list info to the backup file. The check is the same check which is used while backing up category info of manga in library Tested and worked successfully on app installed on Android 12 --- .../data/backup/full/FullBackupManager.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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 f12047891b..586306023f 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 @@ -55,7 +55,7 @@ class FullBackupManager(context: Context) : AbstractBackupManager(context) { backup = Backup( backupManga(databaseManga, flags), - backupCategories(), + backupCategories(flags), emptyList(), backupExtensionInfo(databaseManga), ) @@ -133,10 +133,15 @@ class FullBackupManager(context: Context) : AbstractBackupManager(context) { * * @return list of [BackupCategory] to be backed up */ - private fun backupCategories(): List { - return databaseHelper.getCategories() - .executeAsBlocking() - .map { BackupCategory.copyFrom(it) } + private fun backupCategories(options: Int): List { + // Check if user wants category information in backup + return if (options and BACKUP_CATEGORY_MASK == BACKUP_CATEGORY) { + databaseHelper.getCategories() + .executeAsBlocking() + .map { BackupCategory.copyFrom(it) } + } else { + emptyList() + } } /**