File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 99from aiohttp .client_exceptions import ClientError
1010from collections import defaultdict
1111from django .conf import settings
12+ from django .db .utils import IntegrityError
1213from django .utils import timezone
1314from jinja2 import Template
1415from packaging .utils import canonicalize_name
1718from pypi_simple import ACCEPT_JSON_PREFERRED , ProjectPage
1819from pulpcore .plugin .models import Artifact , Remote
1920from pulpcore .plugin .exceptions import TimeoutException
21+ from pulpcore .plugin .util import get_domain
2022
2123
2224log = logging .getLogger (__name__ )
@@ -277,7 +279,12 @@ def artifact_to_metadata_artifact(filename: str, artifact: Artifact) -> Artifact
277279 metadata_temp .write (metadata_content )
278280 metadata_temp .flush ()
279281 metadata_artifact = Artifact .init_and_validate (metadata_temp .name )
280- metadata_artifact .save ()
282+ try :
283+ metadata_artifact .save ()
284+ except IntegrityError :
285+ metadata_artifact = Artifact .objects .get (
286+ sha256 = metadata_artifact .sha256 , pulp_domain = get_domain ()
287+ )
281288 return metadata_artifact
282289
283290
You can’t perform that action at this time.
0 commit comments