Skip to content

Commit

Permalink
Merge branch '2.10-dev' into 2.11-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
goosemania committed Dec 7, 2016
2 parents 2d5206e + 0a487d3 commit 92654e0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
6 changes: 4 additions & 2 deletions plugins/pulp_rpm/plugins/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1213,8 +1213,10 @@ def merge_pkglists_and_save(self, other):
# the pkglist, because mongoengine does not allow to modify existing items in the list
# and add new items to the list at the same time.
self.save()
self.pkglist += collections_to_add
self.save()

if collections_to_add:
self.pkglist += collections_to_add
self.save()


class PackageGroup(UnitMixin, ContentUnit):
Expand Down
25 changes: 16 additions & 9 deletions plugins/pulp_rpm/plugins/importers/yum/existing.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,20 @@ def check_all_and_associate(wanted, conduit, config, download_deferred, catalog)
named tuples received as input were not found on the server.
:rtype: set
"""
rpm_drpm_srpm = (ids.TYPE_ID_RPM, ids.TYPE_ID_SRPM, ids.TYPE_ID_DRPM)
all_associated_units = set()
for unit_type in rpm_drpm_srpm:
units_generator = repo_controller.get_associated_unit_ids(conduit.repo.repo_id, unit_type)
all_associated_units.update(units_generator)

sorted_units = _sort_by_type(wanted.iterkeys())
for unit_type, values in sorted_units.iteritems():
model = plugin_api.get_unit_model_by_id(unit_type)
# FIXME "fields" does not get used, but it should
# fields = model.unit_key_fields + ('_storage_path',)
unit_generator = (model(**unit_tuple._asdict()) for unit_tuple in values.copy())
for unit in units_controller.find_units(unit_generator):
is_rpm_drpm_srpm = unit_type in (ids.TYPE_ID_RPM, ids.TYPE_ID_SRPM, ids.TYPE_ID_DRPM)
is_rpm_drpm_srpm = unit_type in rpm_drpm_srpm
file_exists = unit._storage_path is not None and os.path.isfile(unit._storage_path)
if is_rpm_drpm_srpm:
# no matter what is the download policy, if existing unit has a valid storage_path,
Expand All @@ -135,14 +141,15 @@ def check_all_and_associate(wanted, conduit, config, download_deferred, catalog)
# package file does not exist and downloading is not deferred.
if not download_deferred and not file_exists:
continue
catalog.add(unit, wanted[unit.unit_key_as_named_tuple].download_path)
if rpm_parse.signature_enabled(config):
try:
rpm_parse.filter_signature(unit, config)
except PulpCodedException as e:
_LOGGER.debug(e)
continue
repo_controller.associate_single_unit(conduit.repo, unit)
if unit.id not in all_associated_units:
catalog.add(unit, wanted[unit.unit_key_as_named_tuple].download_path)
if rpm_parse.signature_enabled(config):
try:
rpm_parse.filter_signature(unit, config)
except PulpCodedException as e:
_LOGGER.debug(e)
continue
repo_controller.associate_single_unit(conduit.repo, unit)
values.discard(unit.unit_key_as_named_tuple)
still_wanted = set()
still_wanted.update(*sorted_units.values())
Expand Down
8 changes: 4 additions & 4 deletions plugins/test/unit/plugins/db/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,8 @@ def test_merge_pkglists_oldstyle_newstyle_same_collection(self, mock_save):
self.assertEqual(existing_erratum.pkglist[0]['_pulp_repo_id'],
uploaded_erratum.pkglist[0]['_pulp_repo_id'])

# make sure save() is called
self.assertEqual(mock_save.call_count, 2)
# make sure save() is called once since no collections were added
self.assertEqual(mock_save.call_count, 1)

@mock.patch('pulp_rpm.plugins.db.models.Errata.save')
def test_merge_pkglists_oldstyle_newstyle_different_collection(self, mock_save):
Expand Down Expand Up @@ -487,8 +487,8 @@ def test_merge_pkglists_newstyle_same_repo_newer(self, mock_update_needed, mock_
self.assertEqual(existing_erratum.pkglist[0]['packages'][0]['version'],
uploaded_erratum.pkglist[0]['packages'][0]['version'])

# make sure save() is called
self.assertEqual(mock_save.call_count, 2)
# make sure save() is called once since no collections were added
self.assertEqual(mock_save.call_count, 1)

@mock.patch('pulp_rpm.plugins.db.models.Errata.save')
@mock.patch('pulp_rpm.plugins.db.models.Errata.update_needed')
Expand Down

0 comments on commit 92654e0

Please sign in to comment.