#536 obsolete removable storage: revoke uri permission

This commit is contained in:
Thibault Deckers 2023-02-28 16:09:30 +01:00
parent 0033795a4e
commit b764bbce9e
2 changed files with 3 additions and 3 deletions

View file

@ -250,8 +250,8 @@ object PermissionManager {
for (uriPermission in context.contentResolver.persistedUriPermissions) {
val uri = uriPermission.uri
val path = StorageUtils.convertTreeDocumentUriToDirPath(context, uri)
if (path != null && !File(path).exists()) {
Log.d(LOG_TAG, "revoke URI permission for obsolete path=$path")
if (path == null || !File(path).exists()) {
Log.d(LOG_TAG, "revoke URI permission for obsolete uri=$uri path=$path")
releaseUriPermission(context, uri)
}
}

View file

@ -693,7 +693,7 @@ object StorageUtils {
class PathSegments(context: Context, fullPath: String) {
var volumePath: String? = null // `volumePath` with trailing "/"
var relativeDir: String? = null // `relativeDir` with trailing "/"
var fileName: String? = null // null for directories
private var fileName: String? = null // null for directories
init {
volumePath = getVolumePath(context, fullPath)