Skip to content
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 DNG/RAW Upload Error #5543

Merged
merged 4 commits into from
Feb 14, 2024

Conversation

shashankiitbhu
Copy link
Contributor

Description (required)

Fixes #5537

What changes did you make and why?
Restrict users to only pick Images whose types are allowed by Wikimedia Commons (as mentioned here: https://commons.wikimedia.org/wiki/Commons:File_types)

Tests performed (required)

Tested 4.2.1-debug-main on Xiaomi 11 Lite NE with API level 33

Screenshots (for UI changes only)

Copy link
Member

@sivaraam sivaraam left a comment

Choose a reason for hiding this comment

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

Thabks for working on this. I took a glance at the change. I suppose we still need to support more formats.

@shashankiitbhu
Copy link
Contributor Author

@sivaraam Made the changes according to the supported formats mentioned on the webpage, Please Review it


val extension = path.substringAfterLast(".", "")
// Check if the extension is one of the allowed types
if (extension.lowercase(Locale.ROOT) in arrayOf("jpg", "jpeg", "png", "svg", "gif", "tiff", "webp", "xcf")) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you please do if ( ! extension.lowercase(Locale.ROOT) in arrayOf(...?

Process exceptional cases first, then go on with the normal flow.
This avoids too may levels of if else.
See https://www.refactoring.com/catalog/replaceNestedConditionalWithGuardClauses.html

Copy link
Member

@nicolas-raoul nicolas-raoul left a comment

Choose a reason for hiding this comment

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

Correctly blocking RAW.
Can still successfully upload JPG.

@nicolas-raoul nicolas-raoul merged commit 2d5b7cc into commons-app:main Feb 14, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Unable to upload DNG / RAW images
3 participants