Commit cba72297 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

(cherry picked from commit 71b91078)
parent 6f6fb37d
...@@ -204,11 +204,12 @@ class MediaParsingService : Service(), DevicesDiscoveryCb, CoroutineScope { ...@@ -204,11 +204,12 @@ class MediaParsingService : Service(), DevicesDiscoveryCb, CoroutineScope {
private suspend fun addDevices(context: Context, addExternal: Boolean) { private suspend fun addDevices(context: Context, addExternal: Boolean) {
val devices = mutableListOf<String>() val devices = mutableListOf<String>()
devices.addAll(DirectoryRepository.getInstance(context).getMediaDirectories()) devices.addAll(DirectoryRepository.getInstance(context).getMediaDirectories())
val knownDevices = if (AndroidDevices.watchDevices) medialibrary.devices else null
for (device in devices) { for (device in devices) {
val isMainStorage = TextUtils.equals(device, AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY) val isMainStorage = TextUtils.equals(device, AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY)
val uuid = FileUtils.getFileNameFromPath(device) val uuid = FileUtils.getFileNameFromPath(device)
if (TextUtils.isEmpty(device) || TextUtils.isEmpty(uuid) || !device.scanAllowed()) continue 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) && medialibrary.addDevice(if (isMainStorage) "main-storage" else uuid, device, !isMainStorage)
if (!isMainStorage && isNew && preselectedStorages.isEmpty()) showStorageNotification(device) 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