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 project path when path contains a symbolic link #6414
Conversation
6df0f48
to
2c8788b
Compare
Nice fix! Could you add a unit test for this please? |
Sorry, I won't have time to do it soon. Besides I have absolutely no idea if symbolic links are possible under Windows. |
No problem there - we have a lot of tests which don't play nice on windows. The most important thing is to get test which works on Linux so that it's covered by the CI infrastructure. (FYI - you CAN make symbolic links in windows) When you get a chance to revisit this PR, the test needs adding in test_qgsproject.py |
I looked into the unit tests and it is much more simple than I thought. Which made me discover another bug when writing projects. The process of file handling / canonicalization is much more complicated than I thought as the project's file is modified sometimes through |
Sorry, I shouldn't have closed the PR (it is really an issue). But not ready to merge yet. Will look more deeply into it as soon as possible. |
2c8788b
to
6d36da6
Compare
Thanks @alexispolti! |
422aa69
to
57f5a6d
Compare
Hi @nyalldawson, |
Hello @nyalldawson , |
Looks good to me! @wonder-sk can you take a look here too? It's in the path resolver and I'd value a second opinion. |
I am wondering whether we could remove the new requirement that the base path had to exist. The path resolver may used in various contexts, not just for project loading/saving, so it would be nice if the class could write relative paths even if the base path does not exist. How about using logic where we would first try to use the canonicalFilePath() and if it fails to resolve the path (returns empty string), we would fall back to absoluteFilePath() as was the case until now? |
57f5a6d
to
5229d2c
Compare
Good idea! PR has been updated and tests added to cover the case where the base path doesn't exist. |
Great, thanks for the quick fix! Looks good to me. |
924a740
to
9d55e1d
Compare
Just faced this bugs and duplicated the PR (#6545), just a doubt on the unit test, but other then this I think it can be merged |
tests/src/core/testqgsproject.cpp
Outdated
QCOMPARE( resolverLegacy.readPath( "/home/qgis/file1.txt" ), QString( "/home/qgis/file1.txt" ) ); | ||
|
||
// Test resolver with symbolic links in path | ||
QTemporaryDir tmpDir; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @alexispolti how this part of code, tests the management of the symbolik link?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, this code doesn't test the management of symbolic link. The management is tested in tests/src/python/test_qgsproject.py
. I updated the comment.
9d55e1d
to
5b2c81b
Compare
@luipir happy for this to be merged if Travis approves? |
travis is happy :) |
@alexispolti great work! Thanks for your responsiveness to the requested changes. I'll make sure this is backported to 3.0 also. |
My pleasure! Thanx to you all! |
Fixes #18337
When project's path contains a symbolic link and relative path are used for layers, all layers are currently stored relative to the symbolic path. Example:
~/Documents/map/map.qgs
~/Documents/map/raster/layer.tif
~/map
poiting to~/Documents/map
If one's opens
~/map/map.gqs
and saves the project, the project will now contains these layers paths :../Documents/map/raster/layer.tif
instead of./raster/layer.tif
This PR should fix it.
Checklist
fixes #11111
in the commit message next to the description[FEATURE]
in the commit message[needs-docs]
in the commit message and containt sufficient information in the commit message to be documentedscripts/prepare-commit.sh
script before each commit