Skip to content

Commit 7b0f13a

Browse files
author
tanpengcheng
committed
[fix] Fix target parent get error.
1 parent b3b824e commit 7b0f13a

File tree

1 file changed

+10
-6
lines changed
  • app/src/main/java/com/tans/tfiletransporter/file

1 file changed

+10
-6
lines changed

app/src/main/java/com/tans/tfiletransporter/file/FileUtils.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,18 @@ fun List<FileLeaf.CommonFileLeaf>.toExploreFiles(): List<FileExploreFile> {
8888
}
8989

9090
fun File.hasTargetParent(targetParent: File): Boolean {
91-
val parent = parentFile
92-
return if (parent == null) {
93-
false
91+
return if (canonicalPath == targetParent.canonicalPath) {
92+
true
9493
} else {
95-
if (parent.canonicalPath == targetParent.canonicalPath) {
96-
true
94+
val parent = parentFile
95+
if (parent == null) {
96+
false
9797
} else {
98-
parent.hasTargetParent(targetParent)
98+
if (parent.canonicalPath == targetParent.canonicalPath) {
99+
true
100+
} else {
101+
parent.hasTargetParent(targetParent)
102+
}
99103
}
100104
}
101105
}

0 commit comments

Comments
 (0)