diff --git a/libqfieldsync/project_checker.py b/libqfieldsync/project_checker.py index 88ef167..3aaeec8 100644 --- a/libqfieldsync/project_checker.py +++ b/libqfieldsync/project_checker.py @@ -103,6 +103,11 @@ def __init__(self, project: QgsProject) -> None: "fn": self.check_layer_has_ascii_filename, "scope": None, }, + { + "type": Feedback.Level.WARNING, + "fn": self.check_external_layers, + "scope": None, + }, { "type": Feedback.Level.WARNING, "fn": self.check_layer_primary_key, @@ -410,3 +415,22 @@ def check_layer_package_prevention( return FeedbackResult(main_msg) return None + + def check_external_layers( + self, layer_source: LayerSource + ) -> Optional[FeedbackResult]: + home_path = Path(self.project.fileName()).parent + + if layer_source.is_file and not layer_source.is_localized_path: + layer_path = Path(layer_source.layer.source()).resolve() + + if home_path not in layer_path.parents: + return FeedbackResult( + self.tr( + 'Layer "{}" is outside the project\'s home directory.' + "This layers may cause issues." + 'Please move the layer within "{}".' + ).format(layer_source.filename, home_path) + ) + + return None