From 2c8f6a263eaea823b107c3d1c19999a8cd3d889d Mon Sep 17 00:00:00 2001 From: euxane Date: Wed, 18 Sep 2024 23:41:13 +0200 Subject: storageprovider: fix findDocumentPath with absolute paths --- .../org/pacien/tincapp/storageprovider/FilesDocumentsProvider.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/pacien/tincapp/storageprovider/FilesDocumentsProvider.kt b/app/src/main/java/org/pacien/tincapp/storageprovider/FilesDocumentsProvider.kt index 1e5fd6f..6af8b1b 100644 --- a/app/src/main/java/org/pacien/tincapp/storageprovider/FilesDocumentsProvider.kt +++ b/app/src/main/java/org/pacien/tincapp/storageprovider/FilesDocumentsProvider.kt @@ -37,7 +37,7 @@ import org.pacien.tincapp.utils.pathUnder import java.io.File import java.io.FileNotFoundException import kotlin.io.path.Path -import kotlin.io.path.name +import kotlin.io.path.pathString import kotlin.io.path.relativeTo class FilesDocumentsProvider : DocumentsProvider() { @@ -125,8 +125,11 @@ class FilesDocumentsProvider : DocumentsProvider() { if (parentDocumentId != null) childPath = childPath.relativeTo(Path(parentDocumentId)) - val components = childPath.asSequence().map { it.name }.toList() - return DocumentsContract.Path(ROOT_ID, listOf(ROOT_DOCUMENT_ID) + components) + val subPaths = (1 .. childPath.nameCount).map { + childPath.subpath(0, it).pathString + }.toList() + + return DocumentsContract.Path(ROOT_ID, listOf(ROOT_DOCUMENT_ID) + subPaths) } override fun isChildDocument(parentDocumentId: String?, documentId: String?): Boolean = -- cgit v1.2.3