Skip to content

Upload: drop duplicate images and display warning in normal selector#6772

Open
Akul-Tyagi wants to merge 4 commits into
commons-app:mainfrom
Akul-Tyagi:fix/normal-selector-duplicate-warning
Open

Upload: drop duplicate images and display warning in normal selector#6772
Akul-Tyagi wants to merge 4 commits into
commons-app:mainfrom
Akul-Tyagi:fix/normal-selector-duplicate-warning

Conversation

@Akul-Tyagi

Copy link
Copy Markdown
Contributor

Fixes #6771

The Problem

In the normal selector flow, duplicate content images (files sharing the same content hash) were silently passed through to the upload screen with no deduplication or user notification. This could result in redundant uploads to the Commons server and created an inconsistency with the custom selector, which already performs duplicate detection (see issue #6764 / PR #6765 ).

The Solution & Justification

I updated the normal selector's completion flow in ContributionController.kt to:

  • Detect duplicate content images before passing the selection to the upload screen.
  • Automatically drop the duplicates, keeping only unique images.
  • Show a warning to the user notifying them that duplicate images were removed, so the count reduction is never silent or confusing.

This brings the normal selector's duplicate handling to full parity with the custom selector fix in #6765 , and ensures a consistent, transparent experience across both upload flows.

Alternative Solutions Considered

I considered passing duplicates through and only showing a warning (preserving the count), similar to what was initially proposed in #6765 . However, per the direction established in #6765 , dropping duplicates and warning the user is the correct approach, as duplicate uploads are genuinely unhelpful and should be prevented at the source rather than silently permitted.

Testing Performed

  • Compiled and ran the betaDebug variant successfully.
  • Passed targeted unit tests: :app:testBetaDebugUnitTest --tests "fr.free.nrw.commons.contributions.ContributionControllerTest"
  • Manually verified that the duplicate warning is shown when identical images are selected via the normal selector.
  • Manually verified that the upload screen receives only the deduplicated set of images.
  • Manually verified that non-duplicate selections pass through normally with no warning shown.

Videos

Before:

Screen_Recording_20260321_181700_Commons.mp4

After:

Screen_Recording_20260321_181512_Commons.mp4

@chrisdebian

Copy link
Copy Markdown

Nice — the SHA1-based dedup logic mirrors #6765's approach for the custom selector, and the wiring (via EXTRA_DUPLICATES_REMOVED) looks correct.

One real problem though: this PR and #6765 both independently add a string resource named duplicates_removed_before_upload to strings.xml, with different wording ("are duplicates and will be removed" here vs. "were duplicates and have been removed" there). Resource names have to be unique per type in the module, so whichever of these two merges second will break the build with a duplicate-resource error. Worth coordinating with #6765 on which wording to keep — probably drop the duplicate here and reuse the one from whichever lands first.

@github-actions

Copy link
Copy Markdown

✅ Generated APK variants!

@Akul-Tyagi

Copy link
Copy Markdown
Contributor Author

Hi @chrisdebian, thank you for pointing out the potential resource collision! Since these two PRs might merge independently, I've renamed the string resource in this PR specifically to normal_selector_duplicates_warning (and updated PR #6765 to use a custom-selector specific name as well). This guarantees there won't be any build errors or merge conflicts regardless of which PR lands first.

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]: Normal selector silently allows duplicate content images without warning

2 participants