Bug report #14458
open datasource in read-only mode
|Affected QGIS version:||2.8.7||Regression?:||No|
|Operating System:||Linux||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||not reproducable|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||22436|
QGIS has some problems when opening datasources in read-only mode (eg. Shapefiles located in directory where the user has only read permission). When you open single file it works, but in log window appears
OGR chyba 4: Unable to open /mnt/home/pc07/Repository/gismentors/shp/osm/pozarni_stanice.shp or /mnt/home/pc07/Repository/gismentors/shp/osm/pozarni_stanice.SHP.
The real problem starts when you try read all layers from directory. Then you get error:
Invalid Data Source: /mnt/home/pc07/Repository/gismentors/shp/ochrana_uzemi is not a valid or recognized data source
and nothing is open.
#1 Updated by Maximilian Krambach over 3 years ago
When opening a directory with read-only shapes in it, I get I get a
"ERROR 4: Failed to open file /tmp/test.shp. It may be corrupt or read-only file accessed in update mode"
This message is created by the OGR provider, not QGIS.
QgsOgrProvider::open() handles the opening of a shapefile by checking if the OGROpen (... ,true) results in a valid layer (here the "unable to open" message is generated by OGR), and if not, proceeds with OGROpen (....,false). --> Layer is opened in read-only mode
I think, if opened as a directory, somewhere in the code it is tried with just OGROpen(....,true), and that fails, resulting in the layers affected to not open at all.