Skip to content

Commit 534a64c

Browse files
committed
make sure we are opening a valid path
1 parent 0187fb3 commit 534a64c

File tree

1 file changed

+9
-1
lines changed
  • app/src/main/kotlin/com/simplemobiletools/filemanager/activities

1 file changed

+9
-1
lines changed

app/src/main/kotlin/com/simplemobiletools/filemanager/activities/MainActivity.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,15 @@ class MainActivity : SimpleActivity() {
9696
}
9797

9898
private fun openPath(path: String) {
99-
(fragment_holder as ItemsFragment).openPath(path)
99+
var newPath = path
100+
val file = File(path)
101+
if (file.exists() && !file.isDirectory) {
102+
newPath = file.parent
103+
} else if (!file.exists()) {
104+
newPath = internalStoragePath
105+
}
106+
107+
(fragment_holder as ItemsFragment).openPath(newPath)
100108
invalidateOptionsMenu()
101109
}
102110

0 commit comments

Comments
 (0)