Commit 71b91078 authored by Geoffrey Métais's avatar Geoffrey Métais

Medialibrary: filter device add on startup

Specific devices require to detect new storages at device boot
parent eed91233
......@@ -204,11 +204,12 @@ class MediaParsingService : Service(), DevicesDiscoveryCb, CoroutineScope {
private suspend fun addDevices(context: Context, addExternal: Boolean) {
val devices = mutableListOf<String>()
val knownDevices = if (AndroidDevices.watchDevices) medialibrary.devices else null
for (device in devices) {
val isMainStorage = TextUtils.equals(device, AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY)
val uuid = FileUtils.getFileNameFromPath(device)
if (TextUtils.isEmpty(device) || TextUtils.isEmpty(uuid) || !device.scanAllowed()) continue
val isNew = (isMainStorage || addExternal)
val isNew = (isMainStorage || (addExternal && knownDevices?.contains(device) != false))
&& medialibrary.addDevice(if (isMainStorage) "main-storage" else uuid, device, !isMainStorage)
if (!isMainStorage && isNew && preselectedStorages.isEmpty()) showStorageNotification(device)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment