diff --git a/ckanext/spatial/harvesters/base.py b/ckanext/spatial/harvesters/base.py index ccb47cbb..9e5111ea 100644 --- a/ckanext/spatial/harvesters/base.py +++ b/ckanext/spatial/harvesters/base.py @@ -467,7 +467,7 @@ def import_stage(self, harvest_object): context.update({ 'ignore_auth': True, }) - p.toolkit.get_action('package_delete')(context, {'id': harvest_object.package_id}) + p.toolkit.get_action('package_purge')(context, {'id': harvest_object.package_id}) log.info('Deleted package {0} with guid {1}'.format(harvest_object.package_id, harvest_object.guid)) return True diff --git a/ckanext/spatial/harvesters/waf.py b/ckanext/spatial/harvesters/waf.py index 8f657e7f..23621af0 100644 --- a/ckanext/spatial/harvesters/waf.py +++ b/ckanext/spatial/harvesters/waf.py @@ -133,6 +133,19 @@ def create_extras(url, date, status): ids = [] + for location in delete: + obj = HarvestObject(job=harvest_job, + extras=create_extras('','', 'delete'), + guid=url_to_ids[location][0], + package_id=url_to_ids[location][1], + ) + model.Session.query(HarvestObject).\ + filter_by(guid=url_to_ids[location][0]).\ + update({'current': False}, False) + + obj.save() + ids.append(obj.id) + for location in new: guid=hashlib.md5(location.encode('utf8','ignore')).hexdigest() obj = HarvestObject(job=harvest_job, @@ -155,19 +168,6 @@ def create_extras(url, date, status): obj.save() ids.append(obj.id) - for location in delete: - obj = HarvestObject(job=harvest_job, - extras=create_extras('','', 'delete'), - guid=url_to_ids[location][0], - package_id=url_to_ids[location][1], - ) - model.Session.query(HarvestObject).\ - filter_by(guid=url_to_ids[location][0]).\ - update({'current': False}, False) - - obj.save() - ids.append(obj.id) - if len(ids) > 0: log.debug('{0} objects sent to the next stage: {1} new, {2} change, {3} delete'.format( len(ids), len(new), len(change), len(delete)))