ckan / ckanext-spatial

Geospatial extension for CKAN
http://docs.ckan.org/projects/ckanext-spatial
126 stars 193 forks source link

skip harvesting during import #191

Open knudmoeller opened 6 years ago

knudmoeller commented 6 years ago

I'm working on a harvester that inherits from ckanext.spatial.harvesters.CSWHarvester. To this end, I overwrite ckanext.spatial.harvesters.SpatialHarvester.get_package_dict.

I'd like to be able to abort harvesting a dataset during import stage (I need to be able to look at the dataset's metadata to decide if I really want to import it), without generating an error.

According to the documentation in https://github.com/ckan/ckanext-harvest#the-harvesting-interface, import_stage should return 'unchanged' in such cases. So, the desired behaviour could be achieved by adding a small test to ckanext.spatial.harvesters.SpatialHarvester.import_stage to check the return value from get_package_dict (if package_dict == 'skip') and return 'unchanged' if true. I've implemented this and it works fine for me.

Does this make sense? If so, I have a pull request ready.

knudmoeller commented 6 years ago

I have submitted a 3-line PR for this: https://github.com/ckan/ckanext-spatial/pull/193