fix: backup fails with 'illegal seek' when a content provider URI is selected - #1176
Open
mvanhorn wants to merge 1 commit into
Open
fix: backup fails with 'illegal seek' when a content provider URI is selected#1176mvanhorn wants to merge 1 commit into
mvanhorn wants to merge 1 commit into
Conversation
Owner
|
Thanks for the tip on the open mode! I likely won't be merging as-is as this doesn't follow contribution guidelines and also I am currently making significant changes to the import and export logic. Also, was any of this created using a coding tool? |
Author
|
Yes, AI tooling was involved - I use Claude to help investigate and draft fixes, with me directing and reviewing the changes. Happy to be upfront about that, and apologies for missing the contribution guidelines. Given you're reworking the import/export logic anyway, feel free to close this and just carry the open-mode detail into your rework if it's useful. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backing up to a location backed by a content provider (e.g. a cloud storage document) fails with "illegal seek".
JsonExportTasktruncated the export file viaFileOutputStream.channel.truncate(), which requires a seekable file descriptor; pipe-backed descriptors from content providers are not seekable. Export and auto backup now truncate throughParcelFileDescriptor.openFileDescriptor(uri, "wt")semantics: a newopenFileForOverwritehelper opens the descriptor for write-truncate and only falls back to channel truncation for plain seekable files.Why this matters
The reporter in #1089 hit this when selecting a backup destination provided by a cloud storage app:
Local file destinations mask the bug because their descriptors are seekable, so the failure only shows up for content-provider URIs, which is exactly the case the storage access framework encourages. Auto backup shares the same write path, so a failing destination also silently breaks scheduled backups until the user re-picks a folder.
Testing
Added JVM unit tests in
JsonExportTaskTestcovering the overwrite helper: truncation for seekable descriptors, the write-truncate path for non-seekable descriptors, and that export output is written through the returned stream. (Full Android instrumentation was not run; the change is confined to the data liberation write path.)Fixes #1089