Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f6bb45ba authored by tibbi's avatar tibbi
Browse files

adding an extra check to avoid deleting unwritable files

parent 1847aa40
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ buildscript {
        propMinSdkVersion = 21
        propTargetSdkVersion = propCompileSdkVersion
        propVersionCode = 1
        propVersionName = '5.1.15'
        propVersionName = '5.1.17'
        kotlin_version = '1.2.71'
    }

+5 −0
Original line number Diff line number Diff line
@@ -487,6 +487,11 @@ fun BaseSimpleActivity.deleteFile(fileDirItem: FileDirItem, allowDeleteFolder: B
fun BaseSimpleActivity.deleteFileBg(fileDirItem: FileDirItem, allowDeleteFolder: Boolean = false, callback: ((wasSuccess: Boolean) -> Unit)? = null) {
    val path = fileDirItem.path
    val file = File(path)
    if (!file.canWrite()) {
        callback?.invoke(false)
        return
    }

    var fileDeleted = !path.startsWith(OTG_PATH) && ((!file.exists() && file.length() == 0L) || file.delete())
    if (fileDeleted) {
        rescanDeletedPath(path) {