-
Notifications
You must be signed in to change notification settings - Fork 28
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] #2396
Merged
Conversation
This file contains 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
APKs built during tests are available here. Scroll down to Artifacts! |
ohassine
approved these changes
Nov 7, 2023
Build 1675 succeeded. The build produced the following APK's: |
saleniuk
requested review from
a team,
typfel,
gongracr,
yamilmedina,
borichellow and
mchenani
and removed request for
a team and
gongracr
November 7, 2023 15:01
alexandreferris
approved these changes
Nov 8, 2023
APKs built during tests are available here. Scroll down to Artifacts! |
Build 1692 succeeded. The build produced the following APK's: |
7 tasks
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.
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
.