Skip to content

Commit

Permalink
update check for offline layers
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Nov 28, 2023
1 parent 223e2db commit bc476b3
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions Mergin/validation.py
Expand Up @@ -194,20 +194,19 @@ def check_offline(self):
"""Check if there are layers that might not be available when offline"""
w = MultipleLayersWarning(Warning.NOT_FOR_OFFLINE)
for lid, layer in self.layers.items():
try:
dp_name = layer.dataProvider().name()
except AttributeError:
# might be vector tiles - no provider name
if layer.type() == QgsMapLayerType.VectorTileLayer:
if "type=mbtiles" not in layer.source() and "type=vtpk" not in layer.source():
w.items.append(layer.name())
if dp_name in QGIS_NET_PROVIDERS + QGIS_DB_PROVIDERS:
if "type=mbtiles" not in layer.source():
# special check for vector tile layers because in QGIS < 3.22 they may not have data provider assigned
if layer.type() == QgsMapLayerType.VectorTileLayer:
# mbtiles/vtpk are always local files
if "type=mbtiles" not in layer.source() and "type=vtpk" not in layer.source():
w.items.append(layer.name())
else:
if layer.type() == QgsMapLayerType.VectorTileLayer:
if "type=mbtiles" not in layer.source() and "type=vtpk" not in layer.source():
w.items.append(layer.name())
continue

dp_name = layer.dataProvider().name()
if dp_name in QGIS_NET_PROVIDERS + QGIS_DB_PROVIDERS:
# raster tiles in mbtiles are always local files
if dp_name == "wms" and "type=mbtiles" in layer.source():
continue
w.items.append(layer.name())

if w.items:
self.issues.append(w)
Expand Down

0 comments on commit bc476b3

Please sign in to comment.