diff options
-rw-r--r-- | app/src/main/java/org/pacien/tincapp/storageprovider/FilesDocumentsProvider.kt | 12 |
1 files changed, 8 insertions, 4 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 38cd562..8b8e2a7 100644 --- a/app/src/main/java/org/pacien/tincapp/storageprovider/FilesDocumentsProvider.kt +++ b/app/src/main/java/org/pacien/tincapp/storageprovider/FilesDocumentsProvider.kt | |||
@@ -166,9 +166,9 @@ class FilesDocumentsProvider : DocumentsProvider() { | |||
166 | } | 166 | } |
167 | 167 | ||
168 | private fun documentIdForFile(file: File): String = | 168 | private fun documentIdForFile(file: File): String = |
169 | if (AppPaths.confDir().isParentOf(file)) { | 169 | if (AppPaths.confDir().isParentOf(file, false)) { |
170 | File(VIRTUAL_ROOT_NETWORKS, file.pathUnder(AppPaths.confDir())).path | 170 | File(VIRTUAL_ROOT_NETWORKS, file.pathUnder(AppPaths.confDir())).path |
171 | } else if (AppPaths.logDir().isParentOf(file)) { | 171 | } else if (AppPaths.logDir().isParentOf(file, false)) { |
172 | File(VIRTUAL_ROOT_LOG, file.pathUnder(AppPaths.logDir())).path | 172 | File(VIRTUAL_ROOT_LOG, file.pathUnder(AppPaths.logDir())).path |
173 | } else { | 173 | } else { |
174 | throw IllegalArgumentException() | 174 | throw IllegalArgumentException() |
@@ -177,8 +177,12 @@ class FilesDocumentsProvider : DocumentsProvider() { | |||
177 | private fun File.pathUnder(parent: File): String = | 177 | private fun File.pathUnder(parent: File): String = |
178 | canonicalPath.removePrefix(parent.canonicalPath) | 178 | canonicalPath.removePrefix(parent.canonicalPath) |
179 | 179 | ||
180 | private fun File.isParentOf(childCandidate: File): Boolean { | 180 | private fun File.isParentOf(childCandidate: File, strict: Boolean = true): Boolean { |
181 | var parentOfChild = childCandidate.canonicalFile.parentFile | 181 | var parentOfChild = childCandidate.canonicalFile |
182 | |||
183 | if (strict) | ||
184 | parentOfChild = parentOfChild.parentFile | ||
185 | |||
182 | while (parentOfChild != null) { | 186 | while (parentOfChild != null) { |
183 | if (parentOfChild.equals(canonicalFile)) return true | 187 | if (parentOfChild.equals(canonicalFile)) return true |
184 | parentOfChild = parentOfChild.parentFile | 188 | parentOfChild = parentOfChild.parentFile |