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

(cherry picked from commit 11c01235ac32c8fd3de864c37cab82367b4a9e41)
(cherry picked from commit 1269d71d1a608515c4243226bc2bbd53f6cab8dd)
This commit is contained in:
nicki 2022-05-09 20:33:40 +05:30 committed by Jobobby04
parent dfa9b7462f
commit 4cee1b3583

View File

@ -75,7 +75,7 @@ class FullBackupManager(context: Context) : AbstractBackupManager(context) {
backup = Backup( backup = Backup(
backupManga(databaseManga, flags), backupManga(databaseManga, flags),
backupCategories(), backupCategories(flags),
emptyList(), emptyList(),
backupExtensionInfo(databaseManga), backupExtensionInfo(databaseManga),
backupSavedSearches(), backupSavedSearches(),
@ -154,10 +154,15 @@ class FullBackupManager(context: Context) : AbstractBackupManager(context) {
* *
* @return list of [BackupCategory] to be backed up * @return list of [BackupCategory] to be backed up
*/ */
private fun backupCategories(): List<BackupCategory> { private fun backupCategories(options: Int): List<BackupCategory> {
return databaseHelper.getCategories() // Check if user wants category information in backup
.executeAsBlocking() return if (options and BACKUP_CATEGORY_MASK == BACKUP_CATEGORY) {
.map { BackupCategory.copyFrom(it) } databaseHelper.getCategories()
.executeAsBlocking()
.map { BackupCategory.copyFrom(it) }
} else {
emptyList()
}
} }
// SY --> // SY -->