Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore of files that have been deleted may fail #728

Closed
t-m-w opened this issue Aug 21, 2024 · 3 comments
Closed

Restore of files that have been deleted may fail #728

t-m-w opened this issue Aug 21, 2024 · 3 comments
Assignees
Labels
Milestone

Comments

@t-m-w
Copy link
Collaborator

t-m-w commented Aug 21, 2024

When testing restoration with #721, I encountered the following issue with a couple of files I had changed/deleted:

E ZipChunkRestore: Failed to restore zip entry for Pictures/Screenshots/Screenshot.png
E ZipChunkRestore: java.lang.IllegalStateException: Only owner is able to interact with pending/trashed item content://media/external/images/media/27
E ZipChunkRestore:         at android.os.Parcel.createExceptionOrNull(Parcel.java:3191)
E ZipChunkRestore:         at android.os.Parcel.createException(Parcel.java:3167)
E ZipChunkRestore:         at android.os.Parcel.readException(Parcel.java:3150)
E ZipChunkRestore:         at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:202)
E ZipChunkRestore:         at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:165)
E ZipChunkRestore:         at android.content.ContentProviderProxy.openAssetFile(ContentProviderNative.java:737)
E ZipChunkRestore:         at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1876)
E ZipChunkRestore:         at android.content.ContentResolver.openOutputStream(ContentResolver.java:1574)
E ZipChunkRestore:         at org.calyxos.backup.storage.UriUtilsKt.openOutputStream(UriUtils.kt:44)
E ZipChunkRestore:         at org.calyxos.backup.storage.restore.FileRestore.restoreFile(FileRestore.kt:134)
E ZipChunkRestore:         at org.calyxos.backup.storage.restore.FileRestore.restoreFile(FileRestore.kt:45)
E ZipChunkRestore:         at org.calyxos.backup.storage.restore.AbstractChunkRestore.restoreFile(AbstractChunkRestore.kt:49)
E ZipChunkRestore:         at org.calyxos.backup.storage.restore.ZipChunkRestore.restoreZipEntry(ZipChunkRestore.kt:87)
E ZipChunkRestore:         at org.calyxos.backup.storage.restore.ZipChunkRestore.restoreZipChunk(ZipChunkRestore.kt:64)
E ZipChunkRestore:         at org.calyxos.backup.storage.restore.ZipChunkRestore.access$restoreZipChunk(ZipChunkRestore.kt:20)
E ZipChunkRestore:         at org.calyxos.backup.storage.restore.ZipChunkRestore$restore$2$1.invokeSuspend(ZipChunkRestore.kt:40)
E ZipChunkRestore:         at org.calyxos.backup.storage.restore.ZipChunkRestore$restore$2$1.invoke(Unknown Source:8)
E ZipChunkRestore:         at org.calyxos.backup.storage.restore.ZipChunkRestore$restore$2$1.invoke(Unknown Source:4)
E ZipChunkRestore:         at org.calyxos.backup.storage.restore.AbstractChunkRestore.getAndDecryptChunk(AbstractChunkRestore.kt:37)
E ZipChunkRestore:         at org.calyxos.backup.storage.restore.ZipChunkRestore.restore(ZipChunkRestore.kt:39)
E ZipChunkRestore:         at org.calyxos.backup.storage.restore.Restore.restoreBackupSnapshot(Restore.kt:118)
E ZipChunkRestore:         at org.calyxos.backup.storage.api.StorageBackup$restoreBackupSnapshot$2.invokeSuspend(StorageBackup.kt:211)
E ZipChunkRestore:         at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E ZipChunkRestore:         at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
E ZipChunkRestore:         at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
E ZipChunkRestore:         at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
E ZipChunkRestore:         at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
E ZipChunkRestore:         at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
E ZipChunkRestore:         at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
E ZipChunkRestore:         at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
@t-m-w t-m-w added the bug label Aug 21, 2024
@grote
Copy link
Collaborator

grote commented Aug 21, 2024

It looks like we are not allowed (anymore?) to access trashed or pending(?) files:

This is thrown from the system here: https://cs.android.com/android/platform/superproject/main/+/main:packages/providers/MediaProvider/src/com/android/providers/media/MediaProvider.java;l=9237;drc=8dd7edc9be5f09967dcdae9be28026c9a56ff1bd

@grote
Copy link
Collaborator

grote commented Aug 21, 2024

This may actually be caused by a fix in #721 where we now restore the owner package name which we missed doing before.

We set the owner and the item we restore to pending. Then we don't own it and are not allowed to write into it. It may be possible to not set the owner initially and when setting the item to not pending also update the owner.

@grote grote self-assigned this Aug 21, 2024
@grote grote added this to the 3.x milestone Aug 21, 2024
@grote
Copy link
Collaborator

grote commented Aug 22, 2024

@t-m-w should be fixed in #721 now. Please test.

@grote grote closed this as completed Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants