Skip to content

Commit

Permalink
Remove duplicated Repository.new_version() method
Browse files Browse the repository at this point in the history
Required PR: pulp/pulpcore#902

[nocoverage]

related to #6463
https://pulp.plan.io/issues/6463

fixes #7844

(cherry picked from commit ef7033b)
  • Loading branch information
dralley authored and daviddavis committed Nov 19, 2020
1 parent e630a0e commit 5981762
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES/7844.bugfix
@@ -0,0 +1 @@
Fixed duplicate key error after incomplete sync task.
9 changes: 5 additions & 4 deletions pulp_rpm/app/models/repository.py
Expand Up @@ -6,10 +6,7 @@
from aiohttp.web_response import Response
from django.conf import settings
from django.contrib.postgres.fields import JSONField
from django.db import (
models,
transaction,
)
from django.db import models, transaction
from pulpcore.plugin.download import DownloaderFactory
from pulpcore.plugin.models import (
Artifact,
Expand Down Expand Up @@ -164,6 +161,10 @@ def new_version(self, base_version=None):
"""
with transaction.atomic():
latest_version = self.versions.latest()
if not latest_version.complete:
latest_version.delete()

version = RepositoryVersion(
repository=self,
number=int(self.next_version),
Expand Down

0 comments on commit 5981762

Please sign in to comment.