Skip to content

feat: add Cloudflare R2 support via account-id and optional list caching#77

Merged
TheMeinerLP merged 1 commit into
mainfrom
feat/r2-support
Jul 13, 2026
Merged

feat: add Cloudflare R2 support via account-id and optional list caching#77
TheMeinerLP merged 1 commit into
mainfrom
feat/r2-support

Conversation

@TheMeinerLP

Copy link
Copy Markdown
Owner

Summary

Ports the useful parts of Tresillo2017's R2 fork (compare/main...Tresillo2017:BlueMapS3Storage:main) cleanly. That fork's diff turned out to contain no actual Java changes despite its CHANGELOG_R2.md describing new R2Storage/R2Configuration/R2FileSystemFactory classes: just three overlapping markdown files and an accidentally-committed node_modules/ (295 files).

R2 is S3-compatible, so it already works through the existing themeinerlp:s3 storage type (their own docs even note this as a "workaround"). Rather than duplicating that as a parallel R2-specific implementation, this adds two small, real conveniences to the existing config instead:

  • account-id: optional Cloudflare account ID. When set (and endpoint-url is left empty), the endpoint is derived automatically as https://<account-id>.r2.cloudflarestorage.com and path-style access is forced on, since R2 only supports path-style.
  • list-cache-ttl-seconds: optional TTL cache for mapIds() (map enumeration), since directory listings are a billed "Class A" operation on R2. Off by default (0); only affects map enumeration at init/reload, not tile reads/writes. Fixed a pre-existing resource leak in mapIds() along the way, the underlying DirectoryStream was never closed.

Consolidates the fork's R2_GUIDE.md/R2_QUICK_START.md/CHANGELOG_R2.md into a single docs/cloudflare-r2.md, and documents both new options plus the existing checksum-validation option (added in #73 but never added to the README) in the main config table.

Test plan

  • ./gradlew compileJava passes
  • ./gradlew spotlessApply — no formatting changes beyond this feature
  • Configure account-id against a real R2 bucket and confirm the endpoint/path-style derivation works end to end

Ports the useful parts of Tresillo2017's R2 fork (compare/main...Tresillo2017:BlueMapS3Storage:main)
cleanly: that fork's diff turned out to contain no actual Java changes despite its
CHANGELOG_R2.md describing new R2Storage/R2Configuration classes, just three overlapping
markdown files and an accidentally committed node_modules/.

R2 is S3-compatible, so it already works through the existing themeinerlp:s3 storage type.
Rather than duplicating that as a parallel R2-specific implementation, this adds:

- account-id: optional Cloudflare account ID. When set (and endpoint-url is left empty), the
  endpoint is derived automatically as https://<account-id>.r2.cloudflarestorage.com and
  path-style access is forced on, since R2 only supports path-style.
- list-cache-ttl-seconds: optional TTL cache for mapIds() (map enumeration), since directory
  listings are a billed "Class A" operation on R2. Off by default (0); only affects map
  enumeration at init/reload, not tile reads/writes. (Fixes a pre-existing resource leak in
  mapIds() along the way — the underlying DirectoryStream was never closed.)

Consolidates the fork's R2_GUIDE.md/R2_QUICK_START.md/CHANGELOG_R2.md into a single
docs/cloudflare-r2.md, and documents both new options plus the existing checksum-validation
option (added in #73 but never added to the README) in the main config table.
@TheMeinerLP
TheMeinerLP merged commit b946aeb into main Jul 13, 2026
4 checks passed
TheMeinerLP added a commit that referenced this pull request Jul 13, 2026
Resolves the squash-merge ancestry gap left by #77's squash-merge:
this branch had #78's ProviderProfile refactor on top of the
pre-squash commit, so a normal merge against main's post-squash tip
showed spurious conflicts on lines that were actually already
superseded (main's version) by this branch's version (confirmed
identical file-by-file diff before this merge).
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.

1 participant