QField icon indicating copy to clipboard operation
QField copied to clipboard

When packaging QGIS to Qfield, Datasources with identical file names (stored in different sub-directories) are silently overwritten

Open Hannes-Ole opened this issue 2 years ago • 2 comments

Describe the issue

When packaging a project that contains multiple layers with the datasources that use the same filename (within different directories), these datasets are overwritten in the qfield folder and only the last one file is kept (that is then the basis for all respective layers). E.g. I have a QGIS project containing Layer A (data source: ./project_version1/standmap.shp) Layer B (data source ./project_version2/standmap.shp)

When packaging for QField, all datasources are only copied to a single directory, where standmap.shp (A) is then overwritten by standmap.shp (B). As a result, a map that would usually show two different datasources now only shows one (see screenshot below). Layer A (data source: ./standmap.shp) Layer B (data source ./standmap.shp)

In my use case, a lot of identically named datasets are automatically generated in subfolders. Manual renaming is a workaround, but very tedious.

Reproduction steps

Steps to reproduce the behavior:

  1. Create two different datasets with the same filename in subfolders
  2. Add them to a QGIS project
  3. Package for QField
  4. Browse to the resulting qfield folder. You will see only one dataset.

Expected behavior

Ideally, QField handles datasources with the same name by sorting them in subfolders or renaming them (e.g. standmap_1.shp, standmap_2.shp, ...). This is an option a lot of file browsers natively offer (do you want to overwrite or rename?) At least, the user should see a warning, that datasources with the same file name are present and only one of these files will be present as datasource for the QField project.

Observed behavior

Datasources with the same name are silently overwritten until the last one is kept as the only datasource that all respective layers use.

Screenshots and GIFs

grafik

Desktop

Reproducible on various systems/versions:

  • OS: Windows 7 / 10
  • QGIS Version 3.16.11 / 3.22.5 / 3.24.3
  • QFieldSync Version 3.x / 4.1.1

Additional information

  • Problem started happening recently, didn't happen in an older version of QField: No
  • Problem can be reliably reproduced, doesn't happen randomly: Yes
  • Problem happens with all files and projects, not only some files or projects: Yes

Hannes-Ole avatar May 20 '22 10:05 Hannes-Ole

Has there been a resolution or workaround for this? I have data that I can't get from qfield because of this issue.

bduncan175 avatar Jul 16 '23 18:07 bduncan175

I don't know of a resolution. My workaround is not using the QField export for projects where I want to keep my folder structure (or where I have datasets with the same name). Since QGIS projects are fully supported in QField, I now switched to simply copying the complete project folder with .qgz instead of using the QField export feature. Obviously this has the drawback of not making use of choosing a subset of layers/data, but it works for me and it forgoes the abovementioned problem.

In your case, I am unsure why you wouldn't be able to get data from QField? Because it doesn't sync to the right layer? Have you tried doing a manual join / merge?

Hope that helps. Best regards!

Hannes-Ole avatar Jul 19 '23 10:07 Hannes-Ole