diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/ImportationFilesManager.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/ImportationFilesManager.kt index ec3f8024d..0699ed518 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/ImportationFilesManager.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/ImportationFilesManager.kt @@ -61,7 +61,7 @@ class ImportationFilesManager @Inject constructor(@ApplicationContext private va private fun getGetLocalCopyFolderOrCopy() = localCopyFolder.apply { if (!exists()) mkdirs() } suspend fun addFiles(uris: List) { - getFiles(uris).forEach { filesToImport.send(it) } + uris.extractPickedFiles().forEach { filesToImport.send(it) } } suspend fun removeFileByUid(uid: String) { @@ -131,17 +131,17 @@ class ImportationFilesManager @Inject constructor(@ApplicationContext private va } } - private suspend fun getFiles(uris: List): Set { + private suspend fun List.extractPickedFiles(): Set { val files = buildSet { - uris.forEach { uri -> - getFile(uri)?.let(::add) + this@extractPickedFiles.forEach { uri -> + extractPickedFile(uri)?.let(::add) } } return files } - private suspend fun getFile(uri: Uri): PickedFile? { + private suspend fun extractPickedFile(uri: Uri): PickedFile? { val contentResolver: ContentResolver = appContext.contentResolver val cursor: Cursor? = contentResolver.query(uri, null, null, null, null)