Skip to content

Commit 4699943

Browse files
committed
avoid deleting whole sd card content by mistake
1 parent 1bb8a85 commit 4699943

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,10 @@ class ItemsFragment : android.support.v4.app.Fragment(), ItemsAdapter.ItemOperat
225225

226226
if (context.needsStupidWritePermissions(item.absolutePath)) {
227227
val document = context.getFileDocument(item.absolutePath, mConfig.treeUri)
228-
document.delete()
228+
229+
// double check we have the uri to the proper file path, not some parent folder
230+
if (document.uri.toString().endsWith(item.absolutePath.getFilenameFromPath()) && !document.isDirectory)
231+
document.delete()
229232
} else {
230233
item.delete()
231234
}

0 commit comments

Comments
 (0)