Skip to content

fix(storage): avoid invalid MediaStore URI on overwrite save#1038

Draft
sjug wants to merge 2 commits intoFossifyOrg:mainfrom
sjug:fix/scoped-storage-overwrite-save
Draft

fix(storage): avoid invalid MediaStore URI on overwrite save#1038
sjug wants to merge 2 commits intoFossifyOrg:mainfrom
sjug:fix/scoped-storage-overwrite-save

Conversation

@sjug
Copy link
Copy Markdown

@sjug sjug commented Apr 29, 2026

Type of change(s)

  • Bug fix
  • Feature / enhancement
  • Infrastructure / tooling (CI, build, deps, tests)
  • Documentation

What changed and why

  • Updates Gallery to use commons 7.0.0, which includes safe MediaStore URI resolution for scoped-storage operations.
  • Changes overwrite-save permission handling to request Android 11+ scoped-storage write grants only when the target file already exists.
  • Resolves the target file through MediaStore before calling MediaStore.createWriteRequest(...), avoiding invalid URIs like content://media/external/images/media/0.
  • Allows new-file save-as paths to proceed without a write request for a non-existent MediaStore item.

This fixes overwrite-save flows such as editing/cropping an image and saving over the original on scoped-storage devices.

Depends on FossifyOrg/commons#339.

Tests performed

  • Clean clone of this branch on the Android build host.
  • ./gradlew :app:assembleFossDebug
  • Installed the debug APK on an Android 16 Pixel device.
  • Runtime-tested the crop overwrite-save flow; save succeeds without Invalid Uri: content://media/external/images/media/0.

Before & after preview

N/A — no UI changes.

Closes the following issue(s)

Checklist

  • I read the contribution guidelines.
  • I manually tested my changes on device/emulator (if applicable).
  • I updated the "Unreleased" section in CHANGELOG.md (if applicable).
  • I have self-reviewed my pull request (no typos, formatting errors, etc.).
  • I understand every change in this pull request.

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.

Illegal argument exception when cropping

1 participant