Skip to content

Commit 4e19c86

Browse files
committed
Fix validation warning for layers stored in project subfolders
1 parent 13de6aa commit 4e19c86

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Mergin/validation.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,18 +203,24 @@ def check_editable_vectors_format(self):
203203
self.issues.append(SingleLayerWarning(lid, Warning.EDITABLE_NON_GPKG))
204204

205205
def check_saved_in_proj_dir(self):
206-
"""Check if layers saved in project's directory."""
206+
"""Check if layers are stored inside the project's directory."""
207207
for lid, layer in self.layers.items():
208208
if lid not in self.layers_by_prov["gdal"] + self.layers_by_prov["ogr"]:
209209
continue
210+
210211
pub_src = layer.publicSource()
212+
211213
if pub_src.startswith("GPKG:"):
212214
pub_src = pub_src[5:]
213215
l_path = pub_src[: pub_src.rfind(":")]
214216
else:
215217
l_path = layer.publicSource().split("|")[0]
216-
l_dir = os.path.dirname(l_path)
217-
if not same_dir(l_dir, self.qgis_proj_dir):
218+
219+
# normalize path
220+
l_path = os.path.abspath(l_path)
221+
222+
# check if layer file is inside project directory
223+
if not is_inside(self.qgis_proj_dir, l_path):
218224
self.issues.append(SingleLayerWarning(lid, Warning.EXTERNAL_SRC))
219225

220226
def check_offline(self):

0 commit comments

Comments
 (0)