Show a GeoJSON icon next to files with a ready cache
GpxStore#tree now reports a "cached" flag per file (reusing the same mtime freshness check geojson() already does); the file tree shows a small curly-braces icon next to any file whose conversion is already on disk, so it's visible which files will toggle on instantly versus which still need to parse.
This commit is contained in:
1 parent
dd0ad6d845
commit
44d235bbcf
4 files changed
+56
-4
No files matched your search
@@ -121,6 +121,30 @@ class GpxStoreTest < Minitest::Test
|
||||
assert_raises(Errno::ENOENT) { @store.geojson("nope.gpx") }
|
||||
end
|
||||
|
||||
def test_tree_reports_cached_true_after_a_successful_save
|
||||
@store.save(folder: "", filename: "ride.gpx", io: StringIO.new(sample_gpx))
|
||||
|
||||
file = @store.tree["children"].find { |c| c["name"] == "ride.gpx" }
|
||||
assert file["cached"]
|
||||
end
|
||||
|
||||
def test_tree_reports_cached_false_for_an_unparseable_file
|
||||
@store.save(folder: "", filename: "bad.gpx", io: StringIO.new("not gpx at all"))
|
||||
|
||||
file = @store.tree["children"].find { |c| c["name"] == "bad.gpx" }
|
||||
refute file["cached"]
|
||||
end
|
||||
|
||||
def test_tree_reports_cached_false_once_the_source_is_resaved
|
||||
path = @store.save(folder: "", filename: "ride.gpx", io: StringIO.new(sample_gpx))
|
||||
FileUtils.touch(@store.resolve_file(path) + ".geojson", mtime: Time.now - 10)
|
||||
File.write(@store.resolve_file(path), sample_gpx)
|
||||
FileUtils.touch(@store.resolve_file(path), mtime: Time.now)
|
||||
|
||||
file = @store.tree["children"].find { |c| c["name"] == "ride.gpx" }
|
||||
refute file["cached"]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def sample_gpx
|
||||
|
||||
Reference in new issue
Block a user