refactor(FileNameUtils): Make cache functions suspend - #3020
Open
FabianDevel wants to merge 5 commits into
Open
Conversation
There was a problem hiding this comment.
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_staysInsideExpectedDirectorycalling 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
executeIntentsuspends in cache resolution, destruction cancels thislifecycleScope, 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 {
… can already be cleaned in onCleared
FabianDevel
force-pushed
the
make-cache-function-suspend
branch
from
August 12, 2026 14:33
495eadc to
fe0113f
Compare
|
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.



No description provided.