Skip to content
Snippets Groups Projects
Commit 2338bd92 authored by Duncan McNamara's avatar Duncan McNamara Committed by Nicolas Pomepuy
Browse files

Ml: fix discovery-failure after onboarding skip

If storage access isn't granted, the medialibrary init will not add the
internal storage as a medialibrary device. After this, it is only
possible to add external devices. So later discovery of internal storage
will fail, not being registered in the medialibrary database.
To fix this, in the late device addition, a check for internal storage
is added.

Fixes #2689
parent 3706c4be
No related branches found
No related tags found
1 merge request!1545Ml: fix discovery-failure after onboarding skip
Pipeline #266854 passed with stage
in 9 minutes and 48 seconds
......@@ -226,9 +226,12 @@ class MediaParsingService : LifecycleService(), DevicesDiscoveryCb {
return
}
}
if (AndroidDevices.externalStorageDirectories.isNotEmpty()) {
val isMainStorage = path.removeFileScheme().startsWith(AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY)
if (isMainStorage) {
medialibrary.addDevice("main-storage", path, false)
} else if (AndroidDevices.externalStorageDirectories.isNotEmpty()) {
for (storagePath in AndroidDevices.externalStorageDirectories) {
if (path.startsWith(storagePath)) {
if (path.removeFileScheme().startsWith(storagePath)) {
val uuid = FileUtils.getFileNameFromPath(path)
if (uuid.isEmpty()) {
exitCommand()
......@@ -240,9 +243,6 @@ class MediaParsingService : LifecycleService(), DevicesDiscoveryCb {
}
}
}
} else {
val uuid = FileUtils.getFileNameFromPath(path)
medialibrary.addDevice(uuid, path, false)
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment