Show what's actually cached per-country, with a delete button per row
CI / check (push) Successful in 17s
CI / deploy (push) Successful in 13s

The only visibility into downloaded data was the whole offline.pmtiles
row, and the only delete was "everything" (whole file + whole cache).
GET /api/offline-tiles/cache lists what's really in
data/geofabrik_cache/ right now — distinct from offline.pmtiles' own
meta.sources, which only reflects the last successful build and can
disagree with both the current selection and the cache (ticked-but-
not-Applied, or built-from-but-since-unticked).

The region picker now shows each cached country's size next to its
checkbox, with its own delete button (DELETE
/api/offline-tiles/cache/:code, already added but unused by the UI
until now) — removing just that entry rather than clearing the whole
cache.
This commit is contained in:
randy committed 2026-09-11 23:39:43 +02:00
1 parent d09d953cbf
commit 78362d51f2
7 files changed
+158 -6

No files matched your search

+17
View File
@@ -338,6 +338,23 @@ class PmtilesBuilderTest < Minitest::Test
assert_nil Maptool::PmtilesBuilder.terrain_meta(@data_dir)
end
def test_cached_extracts_is_empty_before_any_download
assert_empty Maptool::PmtilesBuilder.cached_extracts(@data_dir)
end
# Deliberately still selected — cached_extracts reflects the cache on
# disk, not the current selection or the last build's own meta (see
# cached_extracts' own comment for why those three can all disagree).
def test_cached_extracts_lists_what_was_downloaded
select_regions("SK", "AT")
Maptool::PmtilesBuilder.build_offline(data_dir: @data_dir, download_extract: fake_download).join
extracts = Maptool::PmtilesBuilder.cached_extracts(@data_dir)
assert_equal %w[AT SK], extracts.map { |e| e["code"] }
assert_equal [4, 4], extracts.map { |e| e["size"] } # "fake".bytesize
assert_equal ["Wed, 10 Sep 2026 08:00:01 GMT"] * 2, extracts.map { |e| e["last_modified"] }
end
def test_offline_meta_is_nil_before_any_build
assert_nil Maptool::PmtilesBuilder.offline_meta(@data_dir)
end