Restore files ownership only when file isn't pending anymore
because the system doesn't allow us to open files that we don't own
This commit is contained in:
parent
3683f82363
commit
a2189bc1f7
1 changed files with 3 additions and 2 deletions
|
@ -122,8 +122,6 @@ internal class FileRestore(
|
|||
val contentValues = ContentValues().apply {
|
||||
put(MediaColumns.DISPLAY_NAME, mediaFile.name)
|
||||
put(MediaColumns.RELATIVE_PATH, mediaFile.path)
|
||||
// changing owner requires backup permission
|
||||
put(MediaColumns.OWNER_PACKAGE_NAME, mediaFile.ownerPackageName)
|
||||
put(MediaColumns.IS_PENDING, 1)
|
||||
put(MediaColumns.IS_FAVORITE, if (mediaFile.isFavorite) 1 else 0)
|
||||
}
|
||||
|
@ -139,6 +137,9 @@ internal class FileRestore(
|
|||
contentValues.clear()
|
||||
contentValues.apply {
|
||||
put(MediaColumns.IS_PENDING, 0)
|
||||
// changing owner requires backup permission
|
||||
// done here because we are not allowed to access pending media we don't own
|
||||
put(MediaColumns.OWNER_PACKAGE_NAME, mediaFile.ownerPackageName)
|
||||
}
|
||||
try {
|
||||
contentResolver.update(uri, contentValues, null, null)
|
||||
|
|
Loading…
Reference in a new issue