try the new file deletion only if the old one fails

This commit is contained in:
tibbi 2021-10-10 09:36:06 +02:00
parent ea206806fc
commit 511f080d67

View file

@ -606,16 +606,6 @@ fun BaseSimpleActivity.deleteFile(fileDirItem: FileDirItem, allowDeleteFolder: B
}
fun BaseSimpleActivity.deleteFileBg(fileDirItem: FileDirItem, allowDeleteFolder: Boolean = false, callback: ((wasSuccess: Boolean) -> Unit)? = null) {
if (isRPlus()) {
val fileUris = getFileUrisFromFileDirItems(arrayListOf(fileDirItem))
deleteSDK30Uris(fileUris) { success ->
runOnUiThread {
callback?.invoke(success)
}
}
return
}
val path = fileDirItem.path
val file = File(path)
if (file.absolutePath.startsWith(internalStoragePath) && !file.canWrite()) {
@ -639,6 +629,16 @@ fun BaseSimpleActivity.deleteFileBg(fileDirItem: FileDirItem, allowDeleteFolder:
}
}
} else {
if (isRPlus()) {
val fileUris = getFileUrisFromFileDirItems(arrayListOf(fileDirItem))
deleteSDK30Uris(fileUris) { success ->
runOnUiThread {
callback?.invoke(success)
}
}
return
}
if (getIsPathDirectory(file.absolutePath) && allowDeleteFolder) {
fileDeleted = deleteRecursively(file)
}