diff --git a/app/src/main/java/com/stevesoltys/seedvault/plugins/StoragePluginManager.kt b/app/src/main/java/com/stevesoltys/seedvault/plugins/StoragePluginManager.kt index 7e60b6ff..df12c6e0 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/plugins/StoragePluginManager.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/plugins/StoragePluginManager.kt @@ -72,6 +72,7 @@ class StoragePluginManager( get() { return _storageProperties } + val isOnRemovableDrive: Boolean get() = storageProperties?.isUsb == true init { when (settingsManager.storagePluginType) { diff --git a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt index e1de8f1f..7c1969bf 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt @@ -221,8 +221,7 @@ internal class SettingsViewModel( i.putExtra(EXTRA_START_APP_BACKUP, true) startForegroundService(app, i) } else { - val isUsb = settingsManager.getSafStorage()?.isUsb ?: false - AppBackupWorker.scheduleNow(app, reschedule = !isUsb) + AppBackupWorker.scheduleNow(app, reschedule = !pluginManager.isOnRemovableDrive) } } } @@ -301,20 +300,19 @@ internal class SettingsViewModel( } fun scheduleAppBackup(existingWorkPolicy: ExistingPeriodicWorkPolicy) { - val storage = settingsManager.getSafStorage() ?: error("no storage available") - if (!storage.isUsb && backupManager.isBackupEnabled) { + if (!pluginManager.isOnRemovableDrive && backupManager.isBackupEnabled) { AppBackupWorker.schedule(app, settingsManager, existingWorkPolicy) } } fun scheduleFilesBackup() { - val storage = settingsManager.getSafStorage() ?: error("no storage available") - if (!storage.isUsb && settingsManager.isStorageBackupEnabled()) { + if (!pluginManager.isOnRemovableDrive && settingsManager.isStorageBackupEnabled()) { + val requiresNetwork = pluginManager.storageProperties?.requiresNetwork == true BackupJobService.scheduleJob( context = app, jobServiceClass = StorageBackupJobService::class.java, periodMillis = HOURS.toMillis(24), - networkType = if (storage.requiresNetwork) NETWORK_TYPE_UNMETERED + networkType = if (requiresNetwork) NETWORK_TYPE_UNMETERED else NETWORK_TYPE_NONE, deviceIdle = false, charging = true