From 30087b847a3a0e86eb67ba0b49713e87fed81858 Mon Sep 17 00:00:00 2001 From: OxygenCobalt Date: Thu, 16 Jun 2022 12:16:01 -0600 Subject: [PATCH] music: fix incorrect dir migration Fix an issue with the excluded -> music dir migration where the starting separator would not be removed. --- .../java/org/oxycblt/auxio/settings/SettingsCompat.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/oxycblt/auxio/settings/SettingsCompat.kt b/app/src/main/java/org/oxycblt/auxio/settings/SettingsCompat.kt index 54aba036c..6a132c5fc 100644 --- a/app/src/main/java/org/oxycblt/auxio/settings/SettingsCompat.kt +++ b/app/src/main/java/org/oxycblt/auxio/settings/SettingsCompat.kt @@ -25,6 +25,7 @@ import android.os.Build import android.os.storage.StorageManager import android.util.Log import androidx.core.content.edit +import java.io.File import org.oxycblt.auxio.music.Directory import org.oxycblt.auxio.music.directoryCompat import org.oxycblt.auxio.music.isInternalCompat @@ -37,7 +38,7 @@ import org.oxycblt.auxio.util.queryAll fun handleAccentCompat(prefs: SharedPreferences): Accent { if (prefs.contains(OldKeys.KEY_ACCENT2)) { - Log.d("SettingsCompat", "Migrating ${OldKeys.KEY_ACCENT2}") + Log.d("Auxio.SettingsCompat", "Migrating ${OldKeys.KEY_ACCENT2}") var accent = prefs.getInt(OldKeys.KEY_ACCENT2, 5) @@ -64,7 +65,7 @@ fun handleAccentCompat(prefs: SharedPreferences): Accent { } if (prefs.contains(OldKeys.KEY_ACCENT3)) { - Log.d("SettingsCompat", "Migrating ${OldKeys.KEY_ACCENT3}") + Log.d("Auxio.SettingsCompat", "Migrating ${OldKeys.KEY_ACCENT3}") var accent = prefs.getInt(OldKeys.KEY_ACCENT3, 5) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { @@ -97,14 +98,16 @@ fun handleAccentCompat(prefs: SharedPreferences): Accent { * rolled into this conversion. */ fun handleExcludedCompat(context: Context, storageManager: StorageManager): List { - Log.d("SettingsCompat", "Migrating old excluded database") + Log.d("Auxio.SettingsCompat", "Migrating old excluded database") val db = LegacyExcludedDatabase(context) // /storage/emulated/0 (the old path prefix) should correspond to primary *emulated* storage. val primaryVolume = storageManager.storageVolumesCompat.find { it.isInternalCompat } ?: return emptyList() - val primaryDirectory = primaryVolume.directoryCompat ?: return emptyList() + val primaryDirectory = + (primaryVolume.directoryCompat ?: return emptyList()) + File.separatorChar return db.readPaths().map { path -> val relativePath = path.removePrefix(primaryDirectory) + Log.d("Auxio.SettingsCompat", "Migrate $path -> $relativePath") Directory(primaryVolume, relativePath) } }