fix: do not fail when trying to read metadata of a missing geojson

Some geojson have been removed by mistake time ago (cf #1003), when someone
tries to load a map referencing them, it was until recently just
showing an error message, but since recently we try to get the
metadata from it, and this will crash.
This commit is contained in:
Yohan Boniface 2025-03-28 12:58:07 +01:00
parent 64c7fe1ec9
commit 41264e740f

View file

@ -526,7 +526,10 @@ class DataLayer(NamedModel):
metadata = self.settings metadata = self.settings
if not metadata: if not metadata:
# Fallback to file for old datalayers. # Fallback to file for old datalayers.
data = json.loads(self.geojson.read().decode()) try:
data = json.loads(self.geojson.read().decode())
except FileNotFoundError:
data = {}
metadata = data.get("_umap_options") metadata = data.get("_umap_options")
if not metadata: if not metadata:
metadata = { metadata = {