add an extra check to prevent deleting directories with documentFile
This commit is contained in:
parent
865df01f3a
commit
421214057a
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue