Skip to content

Commit

Permalink
Merge pull request #26 from GSA/bug/clean-harvest-info
Browse files Browse the repository at this point in the history
Bug/clean harvest info
  • Loading branch information
jbrown-xentity committed Oct 7, 2021
2 parents a418ed4 + 925b0ee commit 04586fe
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions ckanext/harvest/plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,31 @@ def before_index(self, pkg_dict):

for key, value in harvest_extras:

# If the harvest extras are there, remove them. This can
# If the harvest extras are there, update them. This can
# happen eg when calling package_update or resource_update,
# which call package_show
if data_dict.get('extras'):
data_dict['extras'][:] = [e for e in data_dict.get('extras', [])
if not e['key'] in harvest_extras]
harvest_not_found = True
harvest_not_found_validated = True
if not data_dict.get('extras'):
data_dict['extras'] = []

for e in data_dict.get('extras'):
if e.get('key') == key:
e.update({'value': value})
harvest_not_found = False
if(harvest_not_found):
data_dict['extras'].append({'key': key, 'value': value})

if not validated_data_dict.get('extras'):
validated_data_dict['extras'] = []

for e in validated_data_dict.get('extras'):
if e.get('key') == key:
e.update({'value': value})
harvest_not_found_validated = False
if(harvest_not_found_validated):
validated_data_dict['extras'].append({'key': key, 'value': value})

if validated_data_dict.get('extras'):
validated_data_dict['extras'][:] = [e for e in validated_data_dict.get('extras', [])
if not e['key'] in harvest_extras]

data_dict['extras'].append({'key': key, 'value': value})

validated_data_dict['extras'].append({'key': key, 'value': value})
# The commented line isn't cataloged correctly, if we pass the
# basic key the extras are prepended and the system works as
# expected.
Expand Down

0 comments on commit 04586fe

Please sign in to comment.