diff --git a/ckanext/spatial/harvesters/waf.py b/ckanext/spatial/harvesters/waf.py index ed51ac48..376e2ed5 100644 --- a/ckanext/spatial/harvesters/waf.py +++ b/ckanext/spatial/harvesters/waf.py @@ -138,6 +138,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, @@ -160,19 +173,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)))