Skip to content

fix: Skip /access request when a file can't be shared - #2095

Merged
tevincent merged 3 commits into
mainfrom
copilot/fix-unnecessary-access-calls
Sep 29, 2026
Merged

tevincent merged 3 commits into
mainfrom
copilot/fix-unnecessary-access-calls

Conversation

Copilot AI commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

The file details and file sharing screens always hit the /access endpoint, even for files the user has no sharing rights on, producing failing/useless requests. Mirrors the iOS fix in Infomaniak/ios-kDrive#2035.

Changes

  • FileDetailsFragment: wraps the getFileShare(fileId) observer in a rights?.canShare == true check on the fetched file details.
  • FileShareDetailsFragment: extracts the share fetching from refreshUi() into a private getFileShare(), invoked only when file.rights?.canShare == true. Share link retrieval (getShareLink) stays unconditional, so direct navigation to this screen for a non-shareable file still renders without the /access call.
if (fileResponse?.rights?.canShare == true) {
    mainViewModel.getFileShare(fileId).observe(viewLifecycleOwner) { shareResponse ->
        shareResponse.data?.let { fileDetailsViewModel.currentFileShare.value = it }
    }
}

Rights.canShare is a non-null Boolean, so == true only guards against a null rights object.

Copilot AI changed the title Avoid unnecessary /access calls when file cannot be shared Skip /access request when a file can't be shared Sep 29, 2026
@PhilippeWeidmann PhilippeWeidmann changed the title Skip /access request when a file can't be shared fix: Skip /access request when a file can't be shared Sep 29, 2026
@tevincent
tevincent marked this pull request as ready for review September 29, 2026 08:54
Copilot AI balanced review requested due to automatic review settings September 29, 2026 08:54

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.

Copilot review overview

🟡 Changes recommended

Share-link retrieval is incorrectly guarded despite the stated requirement that it remain unconditional.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Guards /access requests for files without sharing rights.

Changes:

  • Checks canShare before fetching file-sharing details.
  • Extracts share retrieval into a helper.
File Description
FileDetailsFragment.kt Guards share-detail retrieval.
FileShareDetailsFragment.kt Separates and guards share retrieval.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@tevincent
tevincent force-pushed the copilot/fix-unnecessary-access-calls branch 2 times, most recently from f979df1 to c797146 Compare September 29, 2026 09:17
@tevincent
tevincent enabled auto-merge September 29, 2026 09:17
Copilot AI and others added 3 commits September 29, 2026 11:18
Co-authored-by: PhilippeWeidmann <5843044+PhilippeWeidmann@users.noreply.github.com>
Co-authored-by: PhilippeWeidmann <5843044+PhilippeWeidmann@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@tevincent
tevincent force-pushed the copilot/fix-unnecessary-access-calls branch from c797146 to 7d52606 Compare September 29, 2026 09:18
@sonarqubecloud

Copy link
Copy Markdown

@tevincent
tevincent merged commit 9e9f3c0 into main Sep 29, 2026
9 checks passed
@tevincent
tevincent deleted the copilot/fix-unnecessary-access-calls branch September 29, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants