GeoNode / geonode-importer

MIT License
3 stars 15 forks source link

Cannot overwrite raster files #232

Closed pchevali closed 7 months ago

pchevali commented 8 months ago

Hello,

I am opening this ticket as I think I am facing the same problem as here ( https://github.com/GeoNode/geonode-importer/issues/178) with a geotiff file ( I see that there are no end2end test case for that). It seems to work for geopackage,shp, geojson (test OK) etc but not raster files. The Error that I have is : "Failed to save to Geoserver catalog: 500, Store 'geonode:sdfoklfqls' already exists in workspace 'geonode'"

I tested with a new geotiff name to make sure that there is no multiple layers with same name.

So first import works fine. Second import fails, The rollback task removes the raster in geoserver and I can publish again on the empty geoserver.

When debugging the "_publisher.get_resource(alternate)" from the line https://github.com/GeoNode/geonode-importer/blob/666b81879685d3a118f8855d7dd44953da627fb1/importer/celery_tasks.py#L234

seems to always return None for the geotiff

pchevali commented 8 months ago

I think I found the issue : For rasters "alternate" is computed this way ( when actually overwriting): https://github.com/GeoNode/geonode-importer/blob/666b81879685d3a118f8855d7dd44953da627fb1/importer/handlers/common/raster.py#L291

whereas for vector: https://github.com/GeoNode/geonode-importer/blob/666b81879685d3a118f8855d7dd44953da627fb1/importer/handlers/common/vector.py#L411

I think that for rasters it fails to get the resource as the alternate is built with the workspace as prefix.

mattiagiupponi commented 7 months ago

I think I found the issue : For rasters "alternate" is computed this way ( when actually overwriting):

https://github.com/GeoNode/geonode-importer/blob/666b81879685d3a118f8855d7dd44953da627fb1/importer/handlers/common/raster.py#L291

Ok this was a good hint, but was not the only point. The TIF images in geoserver have their own store, while the _publisher.get_resource(alternate) was checking by default in the geonode store (which is fine for vector but not for raster)

I made some changes to let the store be dynamic based on the resource type.

I'm going to add also an end2end test for this

mattiagiupponi commented 7 months ago

Hi @pchevali The fix is available on master. If you can try it and let me know how it works