Truncate file names to safe length during Android file downloads#73478
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
|
recheck |
0876498 to
e202b0e
Compare
|
@allroundexperts Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppScreen.Recording.2025-10-29.at.3.58.42.AM.movAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
| const path = dirs.DownloadDir; | ||
| // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- Disabling this line for safeness as nullish coalescing works only if the value is undefined or null, and since fileName can be an empty string we want to default to `FileUtils.getFileName(url)` | ||
| const attachmentName = appendTimeToFileName(fileName || getFileName(url)); | ||
| const attachmentName = appendTimeToFileName(truncateFileNameToSafeLength(fileName || getFileName(url))); |
There was a problem hiding this comment.
Appending time to the file name would make the length of file name exceed 70, no? Shouldn't we subtract the length of time from 70 and use it as a safe limit?
There was a problem hiding this comment.
That's right. We should account for the the time appended too.
I'll update the code.
There was a problem hiding this comment.
This is done now in the latest commit.
allroundexperts
left a comment
There was a problem hiding this comment.
Works good. Added a small NAB comment.
|
Oops there are unsigned commits, @victoreronmosele could you re-commit the changes and force push them? Alternatively create another PR with the signed commits
|
|
Thanks @marcochavezf. On it. |
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 1484 files with indirect coverage changes 🚀 New features to boost your workflow:
|
8ac4896 to
b3ca973
Compare
|
@marcochavezf, I've signed the commit and force pushed it now. I've also implemented @allroundexperts suggestion to improve the code change by taking into account the appended timestamp to determine the safe length. I included new unit tests for the update. Screen recording of the download completing successfully, like below: Expensify_FileName_Download_Test.mp4 |
|
Fixing the spell check lint error. |
|
Updated. |
|
I've fixed the lint spell check error @marcochavezf. Kindly help approve again. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/marcochavezf in version: 9.2.43-0 🚀
|
|
🚀 Deployed to production by https://github.com/luacmartins in version: 9.2.43-2 🚀
|

Explanation of Change
Fixed Issues
$ #71955
PROPOSAL: #71955 (comment)
Tests
Upload a .doc file with a long name like: "----------2025-09-11_09_36_21.
446-2025-09-20_04_12_29.481-2025-09-20_06_38_28.278-2025-10-01_03_28_05.899-2025-10-03_23_59_50.039-2025-10-06_22_28_53.119-2025-10-06_23_40_17.151.docx" to a conversation.
Tap on the download button.
See the "Downloaded! Attachment successfully downloaded!" in a popup.
Offline tests
QA Steps
Same as tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Expensify.Android.Download.Doc.PR.Demo.mov
Android: mWeb Chrome
N/A
iOS: Native
N/A
iOS: mWeb Safari
N/A
MacOS: Chrome / Safari
N/A
MacOS: Desktop
N/A