Fix: Adding custom games from USB OTG drives silently fails#1520
Open
sam1am wants to merge 2 commits into
Open
Fix: Adding custom games from USB OTG drives silently fails#1520sam1am wants to merge 2 commits into
sam1am wants to merge 2 commits into
Conversation
getPathFromTreeUri hardcoded /storage/<uuid> when converting a picked document tree to a file path. USB OTG drives on some devices (e.g. Samsung) are only mounted at the path reported by StorageVolume.getDirectory() (such as /mnt/media_rw/<uuid>), with no /storage view at all, so the resolved path never existed and adding a custom game from such a drive silently failed. Resolve the volume root via StorageManager by matching the volume UUID from the tree document ID, preferring /storage/<uuid> when it exists. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
📝 WalkthroughWalkthroughThis PR changes getPathFromTreeUri to accept an Android Context and resolve non-primary volume mount roots using StorageManager (falling back to /storage/ when present). The rememberCustomGameFolderPicker call site is updated to pass LocalContext.current. ChangesStorage Volume Path Resolution
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Addresses CodeRabbit docstring coverage warning. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Description
Adding a custom game from a USB OTG drive silently failed:
getPathFromTreeUrihardcodes/storage/<uuid>when converting the picked document tree to a file path, but USB OTG drives on some devices (verified on a Samsung Galaxy Z Fold6, Android 16) are only mounted at the path reported byStorageVolume.getDirectory()— e.g./mnt/media_rw/<uuid>— with no/storage/<uuid>view at all. The resolved path never existed (stat→ENOENT), soCustomGameScanner.createLibraryItemFromFolderrejected the folder even with All files access granted.The fix resolves the volume root via
StorageManagerby matching the volume UUID from the tree document ID, preferring/storage/<uuid>when it exists (SD cards) and falling back toStorageVolume.getDirectory()(USB OTG). Verified end-to-end on the affected device: a GOG game folder on a USB drive now adds and shows up in the library.Diagnostics captured during testing on the affected device:
Two adjacent pre-existing issues noticed while debugging (not addressed here, happy to file separately):
modernflavor, the custom-game flow forwards users to the system All files access page, but the toggle there is permanently greyed out since the flavor doesn't declareMANAGE_EXTERNAL_STORAGE— a dead end. Onlylegacycan complete this flow.LibraryViewModel.addCustomGameFolderonly logs and returns — the user gets no feedback.Recording
https://www.youtube.com/shorts/mAWQXeKYIus
Type of Change
Checklist
#code-changes, I have discussed this change there and it has been green-lighted. If I do not have access, I have still provided clear context in this PR. If I skip both, I accept that this change may face delays in review, may not be reviewed at all, or may be closed.CONTRIBUTING.md.🤖 Generated with Claude Code
Summary by cubic
Fixes custom-game folder import from USB OTG drives by resolving the correct storage volume root instead of hardcoding
/storage/<uuid>. Users can now add games from OTG drives mounted only under/mnt/media_rw/<uuid>(e.g., Samsung devices).Bug Fixes
StorageManagerby matching the volume UUID; prefer/storage/<uuid>if it exists, else useStorageVolume.getDirectory(), then append the picked path.getPathFromTreeUrito acceptContextand pass it from the folder picker.Refactors
resolveVolumeRoothelper.Written for commit 5b449e3. Summary will update on new commits.
Summary by CodeRabbit