Skip to content
Snippets Groups Projects
Commit cba72297 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Medialibrary: filter device add on startup

Specific devices require to detect new storages at device boot

(cherry picked from commit 71b91078)
parent 6f6fb37d
No related branches found
No related tags found
No related merge requests found
......@@ -204,11 +204,12 @@ class MediaParsingService : Service(), DevicesDiscoveryCb, CoroutineScope {
private suspend fun addDevices(context: Context, addExternal: Boolean) {
val devices = mutableListOf<String>()
devices.addAll(DirectoryRepository.getInstance(context).getMediaDirectories())
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)
}
......
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