Bug report #14458

open datasource in read-only mode

Added by Martin Landa over 8 years ago. Updated over 8 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Data Provider/OGR
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

Description

Hi,

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[3] 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.

History

#1 Updated by Maximilian Krambach over 8 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.

https://github.com/qgis/QGIS/blob/5bb25d8917dc0d494ae46c035f8e019f448c60fb/src/providers/ogr/qgsogrprovider.cpp#l2727
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.

#2 Updated by Giovanni Manghi over 8 years ago

  • Target version changed from 2.16 to Version 2.16

#3 Updated by Nyall Dawson over 8 years ago

  • Status changed from Open to Feedback

I can't reproduce - What method are you using to add all files from a directory?

#4 Updated by Giovanni Manghi over 8 years ago

  • Resolution set to not reproducable
  • Status changed from Feedback to Closed

closing for lack of feedback, please reopen if necessary.

Also available in: Atom PDF