From f2c0732c40041149928cec132475cbf51aac6f32 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 21 Nov 2020 12:22:25 -0500 Subject: [PATCH] Minor cleanup --- .../kanade/tachiyomi/data/backup/BackupCreateService.kt | 7 ++++--- .../eu/kanade/tachiyomi/data/backup/BackupCreatorJob.kt | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupCreateService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupCreateService.kt index 5f2279d90f..f078e91df6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupCreateService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupCreateService.kt @@ -11,7 +11,6 @@ import androidx.core.net.toUri import com.hippo.unifile.UniFile import eu.kanade.tachiyomi.data.backup.full.FullBackupManager import eu.kanade.tachiyomi.data.backup.legacy.LegacyBackupManager -import eu.kanade.tachiyomi.data.backup.models.AbstractBackupManager import eu.kanade.tachiyomi.data.notification.Notifications import eu.kanade.tachiyomi.util.system.acquireWakeLock import eu.kanade.tachiyomi.util.system.isServiceRunning @@ -66,7 +65,6 @@ class BackupCreateService : Service() { */ private lateinit var wakeLock: PowerManager.WakeLock - private lateinit var backupManager: AbstractBackupManager private lateinit var notifier: BackupNotifier override fun onCreate() { @@ -106,7 +104,10 @@ class BackupCreateService : Service() { val uri = intent.getParcelableExtra(BackupConst.EXTRA_URI) val backupFlags = intent.getIntExtra(BackupConst.EXTRA_FLAGS, 0) val backupType = intent.getIntExtra(BackupConst.EXTRA_TYPE, BackupConst.BACKUP_TYPE_LEGACY) - backupManager = if (backupType == BackupConst.BACKUP_TYPE_FULL) FullBackupManager(this) else LegacyBackupManager(this) + val backupManager = when (backupType) { + BackupConst.BACKUP_TYPE_FULL -> FullBackupManager(this) + else -> LegacyBackupManager(this) + } val backupFileUri = backupManager.createBackup(uri, backupFlags, false)?.toUri() val unifile = UniFile.fromUri(this, backupFileUri) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupCreatorJob.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupCreatorJob.kt index e528ff9057..cb726c5fbb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupCreatorJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupCreatorJob.kt @@ -19,13 +19,13 @@ class BackupCreatorJob(private val context: Context, workerParams: WorkerParamet override fun doWork(): Result { val preferences = Injekt.get() - val backupManager = FullBackupManager(context) - val legacyBackupManager = if (preferences.createLegacyBackup().get()) LegacyBackupManager(context) else null val uri = preferences.backupsDirectory().get().toUri() val flags = BackupCreateService.BACKUP_ALL return try { - backupManager.createBackup(uri, flags, true) - legacyBackupManager?.createBackup(uri, flags, true) + FullBackupManager(context).createBackup(uri, flags, true) + if (preferences.createLegacyBackup().get()) { + LegacyBackupManager(context).createBackup(uri, flags, true) + } Result.success() } catch (e: Exception) { Result.failure()