From c6f09565ee409d4a617239bbe135412afc605260 Mon Sep 17 00:00:00 2001 From: Jesper Zedlitz Date: Mon, 16 Jan 2023 09:11:19 +0100 Subject: [PATCH] ignore already delete packages fixes #238 --- ckanext/dcat/harvesters/rdf.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ckanext/dcat/harvesters/rdf.py b/ckanext/dcat/harvesters/rdf.py index 05026f4f..58bc750d 100644 --- a/ckanext/dcat/harvesters/rdf.py +++ b/ckanext/dcat/harvesters/rdf.py @@ -18,7 +18,7 @@ from ckanext.dcat.harvesters.base import DCATHarvester from ckanext.dcat.processors import RDFParserException, RDFParser from ckanext.dcat.interfaces import IDCATRDFHarvester - +from ckan.logic import NotFound log = logging.getLogger(__name__) @@ -278,9 +278,13 @@ def import_stage(self, harvest_object): context = {'model': model, 'session': model.Session, 'user': self._get_user_name(), 'ignore_auth': True} - p.toolkit.get_action('package_delete')(context, {'id': harvest_object.package_id}) - log.info('Deleted package {0} with guid {1}'.format(harvest_object.package_id, - harvest_object.guid)) + try: + p.toolkit.get_action('package_delete')(context, {'id': harvest_object.package_id}) + log.info('Deleted package {0} with guid {1}'.format(harvest_object.package_id, + harvest_object.guid)) + except NotFound: + log.info('Package {0} already deleted.'.format(harvest_object.package_id)) + return True if harvest_object.content is None: