Skip to content

Commit

Permalink
Merge pull request #1253 from dralley/fix-migration
Browse files Browse the repository at this point in the history
Fix migration for cases in which no vendor field is provided
  • Loading branch information
dralley committed Jan 10, 2019
2 parents 223df1f + 3f54007 commit 5772781
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions plugins/pulp_rpm/plugins/migrations/0045_populate_vendor.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ def migrate_rpm(collection, unit):
primary_xml = _HEADER.format(gzip.zlib.decompress(primary_xml))
root_element = ET.fromstring(primary_xml)
delta = {}
delta['vendor'] = root_element.find(
vendor_element = root_element.find(
'./common:package/common:format/rpm:vendor', _NAMESPACES
).text
collection.update_one({'_id': unit['_id']}, {'$set': delta})
)
if vendor_element:
delta['vendor'] = vendor_element.text
collection.update_one({'_id': unit['_id']}, {'$set': delta})


def migrate(*args, **kwargs):
Expand Down

0 comments on commit 5772781

Please sign in to comment.