add an extra check to prevent deleting directories with documentFile
This commit is contained in:
parent
865df01f3a
commit
421214057a
3 changed files with 3 additions and 4 deletions
|
@ -202,7 +202,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
val document = getFileDocument(file.absolutePath, mConfig.treeUri)
|
val document = getFileDocument(file.absolutePath, mConfig.treeUri)
|
||||||
|
|
||||||
// double check we have the uri to the proper file path, not some parent folder
|
// 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()
|
document.delete()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -219,7 +219,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
val document = getFileDocument(file.absolutePath, mConfig.treeUri)
|
val document = getFileDocument(file.absolutePath, mConfig.treeUri)
|
||||||
|
|
||||||
// double check we have the uri to the proper file path, not some parent folder
|
// 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()) {
|
if (document.delete()) {
|
||||||
wereFilesDeleted = true
|
wereFilesDeleted = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,10 +287,9 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
if (needsStupidWritePermissions(mToBeDeleted)) {
|
if (needsStupidWritePermissions(mToBeDeleted)) {
|
||||||
if (!isShowingPermDialog(file)) {
|
if (!isShowingPermDialog(file)) {
|
||||||
val document = getFileDocument(mToBeDeleted, mConfig.treeUri)
|
val document = getFileDocument(mToBeDeleted, mConfig.treeUri)
|
||||||
if (document.canWrite()) {
|
if (document.uri.toString().endsWith(file.absolutePath.getFilenameFromPath()) && !document.isDirectory)
|
||||||
mWasFileDeleted = document.delete()
|
mWasFileDeleted = document.delete()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
mWasFileDeleted = file.delete()
|
mWasFileDeleted = file.delete()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue