From c54b891d081aab0b948f2b460c8c9fed18e23c6c Mon Sep 17 00:00:00 2001 From: Eric Soroos Date: Wed, 3 Jul 2019 13:21:21 +0000 Subject: [PATCH] Fix deleting by appending the id after save, don't clear the current flag till we've actually deleted --- ckanext/dcat/harvesters/_json.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ckanext/dcat/harvesters/_json.py b/ckanext/dcat/harvesters/_json.py index b77f4f7b..ae0b7a3b 100644 --- a/ckanext/dcat/harvesters/_json.py +++ b/ckanext/dcat/harvesters/_json.py @@ -165,11 +165,9 @@ def gather_stage(self, harvest_job): guid=guid, job=harvest_job, package_id=guid_to_package_id[guid], extras=[HarvestObjectExtra(key='status', value='delete')]) - ids.append(obj.id) - model.Session.query(HarvestObject).\ - filter_by(guid=guid).\ - update({'current': False}, False) obj.save() + ids.append(obj.id) + return ids @@ -197,6 +195,11 @@ def import_stage(self, harvest_object): log.info('Deleted package {0} with guid {1}' .format(harvest_object.package_id, harvest_object.guid)) + model.Session.query(HarvestObject).\ + filter_by(guid=harvest_object.guid).\ + filter_by(current=True).\ + update({'current': False}, False) + return True if harvest_object.content is None: