Skip to content

fix: Fix sharedWithMe files sometimes being wrongly queried int the DB - #2055

Draft
FabianDevel wants to merge 3 commits into
mainfrom
fix-sharedWithMe-id
Draft

fix: Fix sharedWithMe files sometimes being wrongly queried int the DB#2055
FabianDevel wants to merge 3 commits into
mainfrom
fix-sharedWithMe-id

Conversation

@FabianDevel

Copy link
Copy Markdown
Contributor

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 sharedWithMeFragment to avoid this problem.

Several sharedWithMe files can have the same id, and thus we were getting the wrong file from the search
Copilot AI review requested due to automatic review settings July 17, 2026 14:24
@FabianDevel FabianDevel added the bug Something isn't working label Jul 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
}
@FabianDevel
FabianDevel marked this pull request as draft July 17, 2026 14:49

@NicolasBourdin88 NicolasBourdin88 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to test

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants