Skip to content

fix(share): preserve Android attachments with duplicate filenames - #57

Merged
dn-presence merged 1 commit into
DartNative:mainfrom
Imgkl:gkl_share_filename_collision
Oct 1, 2026
Merged

dn-presence merged 1 commit into
DartNative:mainfrom
Imgkl:gkl_share_filename_collision

Conversation

@Imgkl

@Imgkl Imgkl commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Sharing /a/report.pdf and /b/report.pdf on Android copies both files to dn_share/report.pdf. The second copy overwrites the first, so both attachment URIs deliver the second report's contents.

Give each attachment an indexed cache subdirectory while preserving its original filename. Clear those subdirectories recursively on the next share.

Validation on an Android 16 / API 36 emulator, using the patched Kotlin bridge, real FileProvider and system chooser, and a separate receiving app:

  • Before: two different report.pdf files produced the same URI and the second report twice. After: distinct URIs deliver both original contents and retain both filenames.
  • Passed six cases: two matching filenames, distinct filenames, repeated source path, three matching filenames, one file, and skipped empty/missing paths.
  • Verified original files remain unchanged and subsequent shares remove stale cached attachments.
  • git diff --check passed.

Validation used an isolated native Android harness; a full dn SDK build was not run.

@Imgkl Imgkl closed this Sep 29, 2026
@Imgkl

Imgkl commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Reopening this for your consideration after checking the upstream implementation.

The filename collision is inherited from the share_plus Android code this plugin was ported from. Its current cache-copy implementation still overwrites files with matching names. fluttercommunity/plus_plugins#3914 includes a proposed fix, but is currently unmerged.

The change here gives each attachment its own cache subdirectory, preventing that overwrite while preserving the original filenames.

Would you be open to merging this fix here? If you'd prefer to keep parity with share_plus and wait for the upstream change, please feel free to close this PR. Happy to follow your preference, and thanks for taking a look.

@Imgkl Imgkl reopened this Sep 29, 2026
@gabrijm

gabrijm commented Oct 1, 2026

Copy link
Copy Markdown

Hello! Thank you for filing this and for the precise information. We’ll take a look soon.

@dn-presence

Copy link
Copy Markdown
Contributor

Thanks for the fix and the clear test cases! We reproduced the overwrite on Android and confirmed your change resolves it. Merging this, and we'll apply it to the published dartnative_share plugin too, so it ships in its next release.

@dn-presence
dn-presence merged commit 1c27967 into DartNative:main Oct 1, 2026
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.

3 participants