Skip to content

refactor(FileNameUtils): Make cache functions suspend - #3020

Open
FabianDevel wants to merge 5 commits into
fix-path-traversal-on-attachmentfrom
make-cache-function-suspend
Open

refactor(FileNameUtils): Make cache functions suspend#3020
FabianDevel wants to merge 5 commits into
fix-path-traversal-on-attachmentfrom
make-cache-function-suspend

Conversation

@FabianDevel

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI balanced review requested due to automatic review settings August 7, 2026 13:34
@FabianDevel FabianDevel added the enhancement Improve or expand upon an existing feature label Aug 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Refactors attachment cache/path operations to run asynchronously on IO dispatchers.

Changes:

  • Makes filename and cache helpers suspendable.
  • Propagates suspend APIs through attachment actions.
  • Updates UI callers to launch coroutines.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
LocalStorageUtils.kt Moves upload and cache path work to IO.
FileNameUtils.kt Makes contained-path resolution suspendable.
AttachmentExt.kt Propagates suspend attachment operations.
AttachableExtensions.kt Makes cache helpers suspendable.
NewMessageFragment.kt Launches attachment opening asynchronously.
ThreadFragment.kt Launches attachment opening asynchronously.
MessageWebViewClient.kt Bridges cache lookups into synchronous interception.
CalendarEventBannerView.kt Uses the view-tree lifecycle for attachment opening.
DownloadAttachmentViewModel.kt Launches cache cleanup asynchronously.
DownloadAttachmentProgressDialog.kt Resolves downloaded attachment intents asynchronously.
AttachmentActionsBottomSheetDialog.kt Launches attachment actions asynchronously.
Suppressed comments (2)

app/src/main/java/com/infomaniak/mail/utils/FileNameUtils.kt:63

  • This suspend signature also leaves FileNameUtilsTest.maliciousFileName_staysInsideExpectedDirectory calling the function from a non-suspend lambda, which fails test compilation. Update that test/helper to execute in a coroutine test context.
suspend fun File.resolveContainedFileName(untrustedName: String): File? = withContext(Dispatchers.IO) {

app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/AttachmentActionsBottomSheetDialog.kt:102

  • As above, the closing listener pops the bottom sheet before this coroutine starts. Once executeIntent suspends in cache resolution, destruction cancels this lifecycleScope, so saving a cached/server attachment to kDrive can silently do nothing. Keep the operation in a surviving scope with a surviving navigation owner, or defer closing until the asynchronous decision is complete.
                lifecycleScope.launch {

Comment thread app/src/main/java/com/infomaniak/mail/utils/FileNameUtils.kt
@FabianDevel
FabianDevel force-pushed the make-cache-function-suspend branch from 495eadc to fe0113f Compare August 12, 2026 14:33
@sonarqubecloud

Copy link
Copy Markdown

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

Labels

enhancement Improve or expand upon an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants