Bug report #21150
Delimitedtext layer saves absolute path when project in relative path mode
|Affected QGIS version:||3.4.4||Regression?:||Yes|
|Operating System:||Windows 7||Easy fix?:||No|
|Pull Request or Patch supplied:||Yes||Resolution:||fixed/implemented|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||28968|
When saving a project with 'Save paths' set to 'relative', the paths for any delimited text layers are saved as absolute 'file:///...' paths in the project file.
Steps to reproduce:
- Create new project and set 'Save paths' to 'relative'
- Add a delimited text layer, such as a CSV file
- Save the project
- Inspect the produced XML file, the 'layer-tree-layer' node will have an absolute path in the 'source' attribute
- Any vector layers etc will have correct relative paths, as expected
When in relative paths mode, the delimited text layer should save its source as a relative path
This breaks being able to produce shareable projects.
Manually rewriting the paths to be relative (e.g. file://../data/file.csv) still works when reloading the project, but on the next save they will be overwritten with absolute paths again.
#5 Updated by Alessandro Pasotti 11 months ago
- Status changed from Reopened to Feedback
I cannot reproduce the bug, I explain it better:
What you originally filed was a bug because the csv path was not set as relative in the tag named "datasource" that is the real path of the data source, and that bug is now fixed: I cannot reproduce it after the patch and it is proteced by a test case which is not failing.
Btw, there is another place where the path is stored and you correctly mentioned it as 'layer-tree-layer', that value is never used inside QGIS (I honestly dont' know what is its purpose).
Did you really try to move the project in another folder (with its relative data) and reproduce the issue or did you just check for 'layer-tree-layer' 'source' value?
I'm pretty sure that the behavior that you described in the ticket is now fixed, it is not fixed the 'layer-tree-layer' 'source' path because it did not produce any effect.
Can you please confirm?
#6 Updated by Adam Liddell 11 months ago
Yes, the absolute path is only appearing in the layer-tree-layer source value now. I wasn't aware that the field was not used within QGIS, hence the reopening when I noticed it was still there.
If it indeed has no effect, I agree this can close again; although it seems unusual that only the CSV nodes get an absolute path in that attribute whereas vector layers do not.
#7 Updated by Alessandro Pasotti 11 months ago
In any event I'm going to fix 'layer-tree-layer' + 'source' too, to avoid any confusion.
The reason why it only affected CSV (well, more precisely, the reason why does not affect shapefiles) is that the CSV uri is internally stored like this:
while shapefile is stored like this:
the extra URL-like stuff was making the check for file existence to fail.