-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: crash when saving file - duplicate names [WPB-5026] #2402
Conversation
APKs built during tests are available here. Scroll down to Artifacts! |
APKs built during tests are available here. Scroll down to Artifacts! |
Build 1699 succeeded. The build produced the following APK's: |
Codecov Report
@@ Coverage Diff @@
## develop #2402 +/- ##
==========================================
Coverage 41.46% 41.47%
+ Complexity 1083 1081 -2
==========================================
Files 344 344
Lines 12408 12389 -19
Branches 1630 1629 -1
==========================================
- Hits 5145 5138 -7
+ Misses 6779 6767 -12
Partials 484 484
... and 4 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
APKs built during tests are available here. Scroll down to Artifacts! |
Build 1722 succeeded. The build produced the following APK's: |
Cherry pick from the original PR:
kalium
PR Submission Checklist for internal contributors
The PR Title
SQPIT-764
The PR Description
What's new in this PR?
Issues
On some devices, the app is randomly crashing when downloading a file.
java.lang.IllegalStateException: Failed to build unique file: /storage/emulated/0/Download/image owner_package_name=com.waz.zclient.dev _display_name=image mime_type=application/octet-stream _data=/storage/emulated/0/Download/image _size=246181 is_download=1 relative_path=Download/
Causes (Optional)
In theory,
ContentResolver
handles duplicate names itself and we use it on Android 10 and up, but it usesbuildUniqueFileWithExtension
fromFileUtils
which looks like this:so it works but up to 32 times, after that it returns this exact crash.
Solutions
Use our function
findFirstUniqueName
also for Android versions that useContentResolver
, to also determine unique filename ourselves.This
ContentResolver
also changes the file names to remove disallowed characters (like colon or quotation mark) so it's then not possible to compare these names, so it's required to do the same (also to not allow for creating files with invalid names), that's whysanitizeFilename
is also added.Testing
Test Coverage (Optional)
How to Test
Try to save the same file more than 32 times.
PR Post Submission Checklist for internal contributors (Optional)
PR Post Merge Checklist for internal contributors
References
feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764
.