Skip to content

Commit

Permalink
Restore files ownership only when file isn't pending anymore
Browse files Browse the repository at this point in the history
because the system doesn't allow us to open files that we don't own
  • Loading branch information
grote committed Aug 22, 2024
1 parent 3683f82 commit a2189bc
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
Expand Down

0 comments on commit a2189bc

Please sign in to comment.