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

Unable to open a project in Windows via drag&drop, when the project is stored in a GPKG file on a mapped drive or a drive that is not C: #46969

Open
2 tasks done
cxcandid opened this issue Jan 24, 2022 · 11 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Data Provider Related to specific vector, raster or mesh data providers Project Windows Related to Windows operating system

Comments

@cxcandid
Copy link

cxcandid commented Jan 24, 2022

What is the bug or the crash?

We cannot open a QGIS project in Windows via drag&drop, when the project is stored in a GPKG file on a mapped drive. QGIS complains that the URI is invalid. Everything works fine if we open the project via QGIS Browser, or move the GPKG file to a local drive. "Open From... > Geopackage" works as well. There is even no error when we open a project from a GPKG file stored in SharePoint using WebDAV.

Steps to reproduce the issue

Store a QGIS project inside a GPKG file and put that file on a mapped drive (i.e. X:).
Then try to open the project via file drag&drop.

Versions

QGIS 3.22.3 Windows

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

  • I tried with a new QGIS profile

Additional context

No response

@cxcandid cxcandid added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Jan 24, 2022
@gioman gioman added Project Data Provider Related to specific vector, raster or mesh data providers labels Jan 24, 2022
@elpaso elpaso added the Windows Related to Windows operating system label Jan 28, 2022
@jfmoyen
Copy link

jfmoyen commented Feb 8, 2022

Similar issue using a physical drive on the same computer (D:).
3.22.3-Białowieża
Révision 1628765
Windows 10

@gioman
Copy link
Contributor

gioman commented Feb 8, 2022

Similar issue using a physical drive on the same computer (D:).
3.22.3-Białowieża
Révision 1628765
Windows 10

@jfmoyen can't confirm this, just tested on Win10 and 3.22.3

@jfmoyen
Copy link

jfmoyen commented Feb 8, 2022

Interesting, so there would be something wrong with my file. Let me investigate, I'll come back to you. I wonder if it may be related to the OP's issue.

@jfmoyen
Copy link

jfmoyen commented Feb 8, 2022

GEO001M_exp.zip

This, for instance, does open happily if I drag it from C:\users\me\documents but not from D:\GISData\France\BRGM\France_1_000000

No, the D-path does not contain any space or weird characters, and it is not specially long, either.

This is the actual error I get:
image

Please let me know if there is something else you'd like me to try.

@gioman
Copy link
Contributor

gioman commented Feb 8, 2022

This is the actual error I get:

@jfmoyen yes, I was too quick before, D&D from d: drive and the selecting the project saved in the GPKG will result in that error.

@gioman gioman changed the title Unable to open a project in Windows via drag&drop, when the project is stored in a GPKG file on a mapped drive Unable to open a project in Windows via drag&drop, when the project is stored in a GPKG file on a mapped drive or a drive that is not C: Feb 8, 2022
@cxcandid
Copy link
Author

cxcandid commented Feb 8, 2022

I can confirm that it only works from C: drive.

@cxcandid
Copy link
Author

cxcandid commented Nov 9, 2022

Is there anything we can do to get this issue solved? ... sponsoring? 🤔🙄😊

@nicogodet
Copy link
Member

@cxcandid Sponsoring could be a solution indeed

@cxcandid
Copy link
Author

In QGIS 3.30.3 (Windows) D&D works from D: drive as well, but not from USB and not from any mapped network drive.
If I open a network directory via UNC path in Windows Explorer, D&D works pretty well.

@cxcandid
Copy link
Author

In QGIS 3.36.0 project opening from GPKG via drag&drop doesn't work from D: drive anymore 🙁. C: drive is ok and UNC path is supported.

@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented Mar 18, 2024

Hi @elpaso, I've seen that you previously fixed with PR #33265 the logic for handling the project in a GeoPackage file. Anyway it seems it is still not working on Windows when the GeoPackage file is in a drive different from the C: drive (actually QGIS install drive letter) and such GeoPackage file is dropped onto the QGIS main window.

I've tracked down the issue to the point that in such case (e.g. a gpkg file file_name.gpkg in D:\) QgsGeoPackageProjectStorage::readProject is called with uri = geopackage://D:/file_name.gpkg?projectName=project_name (see the double slash).
Then, in QgsGeoPackageProjectStorage::decodeUri, the uri string doesn't match with the QRegularExpression (^[A-Za-z]:), so it is checked the existence (QFile::exists) of url.path() (where url = QUrl::fromEncoded( uri.toUtf8() ) = QUrl('geopackage://d/file_name.gpkg?projectName=project_name') ) which in this case is /file_name.gpkg (see the missing drive letter) and thus QFile searches the file in C: (actually in the QGIS install drive letter) and it doesn't find it.

On the contrary, when such GeoPackage file is opened via Project->Open From->GeoPackage, then QgsGeoPackageProjectStorage::readProject is called with uri = geopackage:D:/file_name.gpkg?projectName=project_name (see the missing double slash), so it is checked the existence (QFile::exists) of url.path() (where url = QUrl::fromEncoded( uri.toUtf8() ) = QUrl('geopackage:D:/file_name.gpkg?projectName=project_name') ) which in this case is D:/file_name.gpkg (see the presence of the drive letter) and it correctly finds it.

Maybe you know a simple way to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Data Provider Related to specific vector, raster or mesh data providers Project Windows Related to Windows operating system
Projects
None yet
Development

No branches or pull requests

6 participants