Bug report #21495

Deleting shapefiles from the browser panel does not delete all the files

Added by Harrissou Santanna over 1 year ago. Updated over 1 year ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Browser
Affected QGIS version:3.4.5 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:up/downstream
Crashes QGIS or corrupts data:No Copied to github as #:29312

Description

I have a shapefile I deleted from the QGIS browser panel (right-click --> Delete file xxx).
While dbf, shx, shp and prj files have gone, it let me with cpg and qpj files. It could be nice to have them removed too.


Related issues

Related to QGIS Application - Feature request #17032: delete (or propose to) all files of a shapefile with browser Closed 2017-08-18

History

#1 Updated by Alessandro Pasotti over 1 year ago

  • Resolution set to up/downstream
  • Status changed from Open to Closed

I'm afraid this goes upstream to OGR/GDAL: we are using OGR calls to delete the OGR layers: GDALDatasetDeleteLayer()

#2 Updated by Andrea Giudiceandrea over 1 year ago

Alessandro Pasotti wrote:

I'm afraid this goes upstream to OGR/GDAL: we are using OGR calls to delete the OGR layers: GDALDatasetDeleteLayer()

It seems to me that this is true for .cpg files only.

The .qpj files are created by QGIS, not by GDAL/OGR, so they should be deleted by QGIS.

In fact QgsVectorFileWriter::deleteShapeFile() deletes .qpj files along with ".shp", ".shx", ".dbf", ".prj", ".qix" files.

#3 Updated by Andrea Giudiceandrea over 1 year ago

Andrea Giudiceandrea wrote:

It seems to me that this is true for .cpg files only.

Just now this was super fast fixed https://github.com/OSGeo/gdal/issues/1405 in GDAL/OGR master https://github.com/OSGeo/gdal/commit/41d8da793ee9a5360ad4ec7e3d97ace2913e11c5

The .qpj files are created by QGIS, not by GDAL/OGR, so they should be deleted by QGIS.

Anyway, now GDAL/OGR GDALDatasetDeleteLayer() / OGRShapeDataSource::DeleteLayer(), in master, take care of deletion of .qpj files also https://github.com/OSGeo/gdal/commit/391a0c719c83be1c51e92717cc730edcd110062b

#4 Updated by Andrea Giudiceandrea over 1 year ago

#5 Updated by Harrissou Santanna over 1 year ago

Thanks Andrea for having reported upstream.

Also available in: Atom PDF