Skip to content

Commit

Permalink
Don't assume SAF-based storage is available
Browse files Browse the repository at this point in the history
it may be WebDAV now
  • Loading branch information
grote committed Apr 25, 2024
1 parent 0e51c00 commit 0b4bd09
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class StoragePluginManager(
get() {
return _storageProperties
}
val isOnRemovableDrive: Boolean get() = storageProperties?.isUsb == true

init {
when (settingsManager.storagePluginType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0b4bd09

Please sign in to comment.