From 46999432d94c289ef41fcb5a3688a2f0216d90d3 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 3 Dec 2016 22:48:54 +0100 Subject: [PATCH] avoid deleting whole sd card content by mistake --- .../simplemobiletools/filemanager/fragments/ItemsFragment.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt index bc4bf2b5..6d701c4c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt @@ -225,7 +225,10 @@ class ItemsFragment : android.support.v4.app.Fragment(), ItemsAdapter.ItemOperat if (context.needsStupidWritePermissions(item.absolutePath)) { val document = context.getFileDocument(item.absolutePath, mConfig.treeUri) - document.delete() + + // double check we have the uri to the proper file path, not some parent folder + if (document.uri.toString().endsWith(item.absolutePath.getFilenameFromPath()) && !document.isDirectory) + document.delete() } else { item.delete() }