Don't assume SAF-based storage is available
it may be WebDAV now
This commit is contained in:
parent
0e51c00bca
commit
0b4bd09e7d
2 changed files with 6 additions and 7 deletions
|
@ -72,6 +72,7 @@ class StoragePluginManager(
|
||||||
get() {
|
get() {
|
||||||
return _storageProperties
|
return _storageProperties
|
||||||
}
|
}
|
||||||
|
val isOnRemovableDrive: Boolean get() = storageProperties?.isUsb == true
|
||||||
|
|
||||||
init {
|
init {
|
||||||
when (settingsManager.storagePluginType) {
|
when (settingsManager.storagePluginType) {
|
||||||
|
|
|
@ -221,8 +221,7 @@ internal class SettingsViewModel(
|
||||||
i.putExtra(EXTRA_START_APP_BACKUP, true)
|
i.putExtra(EXTRA_START_APP_BACKUP, true)
|
||||||
startForegroundService(app, i)
|
startForegroundService(app, i)
|
||||||
} else {
|
} else {
|
||||||
val isUsb = settingsManager.getSafStorage()?.isUsb ?: false
|
AppBackupWorker.scheduleNow(app, reschedule = !pluginManager.isOnRemovableDrive)
|
||||||
AppBackupWorker.scheduleNow(app, reschedule = !isUsb)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,20 +300,19 @@ internal class SettingsViewModel(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun scheduleAppBackup(existingWorkPolicy: ExistingPeriodicWorkPolicy) {
|
fun scheduleAppBackup(existingWorkPolicy: ExistingPeriodicWorkPolicy) {
|
||||||
val storage = settingsManager.getSafStorage() ?: error("no storage available")
|
if (!pluginManager.isOnRemovableDrive && backupManager.isBackupEnabled) {
|
||||||
if (!storage.isUsb && backupManager.isBackupEnabled) {
|
|
||||||
AppBackupWorker.schedule(app, settingsManager, existingWorkPolicy)
|
AppBackupWorker.schedule(app, settingsManager, existingWorkPolicy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun scheduleFilesBackup() {
|
fun scheduleFilesBackup() {
|
||||||
val storage = settingsManager.getSafStorage() ?: error("no storage available")
|
if (!pluginManager.isOnRemovableDrive && settingsManager.isStorageBackupEnabled()) {
|
||||||
if (!storage.isUsb && settingsManager.isStorageBackupEnabled()) {
|
val requiresNetwork = pluginManager.storageProperties?.requiresNetwork == true
|
||||||
BackupJobService.scheduleJob(
|
BackupJobService.scheduleJob(
|
||||||
context = app,
|
context = app,
|
||||||
jobServiceClass = StorageBackupJobService::class.java,
|
jobServiceClass = StorageBackupJobService::class.java,
|
||||||
periodMillis = HOURS.toMillis(24),
|
periodMillis = HOURS.toMillis(24),
|
||||||
networkType = if (storage.requiresNetwork) NETWORK_TYPE_UNMETERED
|
networkType = if (requiresNetwork) NETWORK_TYPE_UNMETERED
|
||||||
else NETWORK_TYPE_NONE,
|
else NETWORK_TYPE_NONE,
|
||||||
deviceIdle = false,
|
deviceIdle = false,
|
||||||
charging = true
|
charging = true
|
||||||
|
|
Loading…
Reference in a new issue