Properly migrate existing users to new plugin setup
This commit is contained in:
parent
a95ba41196
commit
0e51c00bca
1 changed files with 17 additions and 5 deletions
|
@ -102,11 +102,23 @@ class SettingsManager(private val context: Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val storagePluginType: StoragePluginEnum?
|
internal val storagePluginType: StoragePluginEnum?
|
||||||
get() = prefs.getString(PREF_KEY_STORAGE_PLUGIN, StoragePluginEnum.SAF.name)?.let {
|
get() {
|
||||||
try {
|
val savedType = prefs.getString(PREF_KEY_STORAGE_PLUGIN, null)
|
||||||
StoragePluginEnum.valueOf(it)
|
return if (savedType == null) {
|
||||||
} catch (e: IllegalArgumentException) {
|
// check if this is an existing user that needs to be migrated
|
||||||
null
|
// this check could be removed after a reasonable migration time (added 2024)
|
||||||
|
if (prefs.getString(PREF_KEY_STORAGE_URI, null) != null) {
|
||||||
|
prefs.edit()
|
||||||
|
.putString(PREF_KEY_STORAGE_PLUGIN, StoragePluginEnum.SAF.name)
|
||||||
|
.apply()
|
||||||
|
StoragePluginEnum.SAF
|
||||||
|
} else null
|
||||||
|
} else savedType.let {
|
||||||
|
try {
|
||||||
|
StoragePluginEnum.valueOf(it)
|
||||||
|
} catch (e: IllegalArgumentException) {
|
||||||
|
null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue