fix: Fix sharedWithMe files sometimes being wrongly queried int the DB - #2055
Draft
FabianDevel wants to merge 3 commits into
Draft
fix: Fix sharedWithMe files sometimes being wrongly queried int the DB#2055FabianDevel wants to merge 3 commits into
FabianDevel wants to merge 3 commits into
Conversation
Several sharedWithMe files can have the same id, and thus we were getting the wrong file from the search
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes ambiguous SharedWithMe database lookups when file IDs overlap across drives.
Changes:
- Adds drive-scoped UID lookup.
- Uses it for previews and folder-rights checks.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
FileController.kt |
Adds UID-based retrieval logic. |
SharedWithMeFragment.kt |
Uses drive-aware lookups. |
| realm.copyFromRealm(it, 1) | ||
| realm.run { | ||
| where(File::class.java) | ||
| .equalTo(File::uid.name, "${fileId}_${userDrive?.driveId}") |
Comment on lines
+160
to
+162
| fun getFileByUidOrId(fileId: Int, userDrive: UserDrive? = null): File? { | ||
| return userDrive?.let { getFileByUid(fileId, userDrive = it) } ?: getFileById(fileId, userDrive = null) | ||
| } |
NicolasBourdin88
approved these changes
Jul 17, 2026
FabianDevel
marked this pull request as draft
July 17, 2026 14:49
|
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.



As SharedWithMe files are all in a single DB but originate from multiple drives, several files can have the same fileId (because it's their id on their parent's drive).
We were querying the first matching id from the DB, thus we could have the wrong file.
With this new getFileByUidOrId, we now query the file by their uid in the
sharedWithMeFragmentto avoid this problem.