add an extra check to prevent deleting directories with documentFile

This commit is contained in:
tibbi 2016-12-01 23:42:47 +01:00
parent 865df01f3a
commit 421214057a
3 changed files with 3 additions and 4 deletions

View file

@ -202,7 +202,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
val document = getFileDocument(file.absolutePath, mConfig.treeUri)
// double check we have the uri to the proper file path, not some parent folder
if (document.uri.toString().endsWith(file.absolutePath.getFilenameFromPath()))
if (document.uri.toString().endsWith(file.absolutePath.getFilenameFromPath()) && !document.isDirectory)
document.delete()
}
} else {

View file

@ -219,7 +219,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
val document = getFileDocument(file.absolutePath, mConfig.treeUri)
// double check we have the uri to the proper file path, not some parent folder
if (document.uri.toString().endsWith(file.absolutePath.getFilenameFromPath())) {
if (document.uri.toString().endsWith(file.absolutePath.getFilenameFromPath()) && !document.isDirectory) {
if (document.delete()) {
wereFilesDeleted = true
}

View file

@ -287,9 +287,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
if (needsStupidWritePermissions(mToBeDeleted)) {
if (!isShowingPermDialog(file)) {
val document = getFileDocument(mToBeDeleted, mConfig.treeUri)
if (document.canWrite()) {
if (document.uri.toString().endsWith(file.absolutePath.getFilenameFromPath()) && !document.isDirectory)
mWasFileDeleted = document.delete()
}
}
} else {
mWasFileDeleted = file.delete()