Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Prevent duplicate content #3318

Merged
merged 1 commit into from Feb 16, 2018
Merged

Prevent duplicate content #3318

merged 1 commit into from Feb 16, 2018

Conversation

daviddavis
Copy link
Contributor

@daviddavis daviddavis commented Feb 9, 2018

Prevent users/plugins from adding content to a repo version if that content would otherwise already exist for that repo version.

Added validation to the viewset so we don't kick off a task and a nice user error gets return if the content addition/removal isn't allowed. Also added validation to the model mostly for the benefit of plugins who might call these methods directly.

closes #3304
https://pulp.plan.io/issues/3304

@daviddavis daviddavis added the 3.0 label Feb 9, 2018
association.save()

if self.content_exists(content):
raise DuplicateContentException(content, self.repository)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to raise an exception here? Perhaps add_content() should be idempotent.

@@ -395,6 +407,9 @@ def remove_content(self, content):
if self.complete:
raise ResourceImmutableError(self)

if not self.content_exists(content):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to raise an exception here? Perhaps remove_content() should be idempotent.

Prevent users/plugins from adding content to a repo version if that
content would otherwise already exist for that repo version.

closes #3304
https://pulp.plan.io/issues/3304
@daviddavis
Copy link
Contributor Author

@jortel updated the PR based on your feedback.

Copy link
Contributor

@jortel jortel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@daviddavis
Copy link
Contributor Author

ok test

@daviddavis daviddavis merged commit f4ebdf7 into pulp:3.0-dev Feb 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants