Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix checking for external layers relative to the project file #99

Merged
merged 1 commit into from
Dec 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions libqfieldsync/project_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,18 +419,23 @@ def check_layer_package_prevention(
def check_external_layers(
self, layer_source: LayerSource
) -> Optional[FeedbackResult]:
home_path = Path(self.project.fileName()).parent
if (
not layer_source.is_file
or not layer_source.filename
or layer_source.is_localized_path
):
return None

if layer_source.is_file and not layer_source.is_localized_path:
layer_path = Path(layer_source.layer.source()).resolve()
home_path = Path(self.project.fileName()).parent.resolve()
layer_path = Path(layer_source.filename).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)
)
if home_path and home_path not in layer_path.parents:
return FeedbackResult(
self.tr(
'Layer "{}" is outside the project\'s home directory. '
"QFieldSync may not transfer your layer. "
'Please move the file to "{}".'
m-kuhn marked this conversation as resolved.
Show resolved Hide resolved
).format(layer_source.filename, home_path)
)

return None
Loading