Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
content=self.content.stored_model,
artifact=self._stored_model)
content_artifact.save()
except IntegrityError:
content_artifact = ContentArtifact.objects.get(
relative_path=self.relative_path,
content=self.content.stored_model)
if self._stored_model:
content_artifact.artifact = self._stored_model
content_artifact.save()
digests = {f: getattr(self._model, f) for f in Artifact.DIGEST_FIELDS}
try:
with transaction.atomic():
remote_artifact = RemoteArtifact(
url=self.url,
remote=self.remote,
content_artifact=content_artifact,
size=self._model.size,
**digests)
remote_artifact.save()
except IntegrityError:
q_set = RemoteArtifact.objects.filter(
remote=self.remote,
content_artifact=content_artifact)
q_set.update(
url=self.url,
size=self._model.size,
**digests)
remote_artifact_data = {
'url': declarative_artifact.url,
'size': declarative_artifact.artifact.size,
'md5': declarative_artifact.artifact.md5,
'sha1': declarative_artifact.artifact.sha1,
'sha224': declarative_artifact.artifact.sha224,
'sha256': declarative_artifact.artifact.sha256,
'sha384': declarative_artifact.artifact.sha384,
'sha512': declarative_artifact.artifact.sha512,
'remote': declarative_artifact.remote,
}
remote_artifact_map[content_artifact.relative_path] = remote_artifact_data
for content_artifact in ContentArtifact.objects.bulk_create(content_artifact_bulk):
remote_artifact_data = remote_artifact_map.pop(content_artifact.relative_path)
new_remote_artifact = RemoteArtifact(
content_artifact=content_artifact, **remote_artifact_data
)
remote_artifact_bulk.append(new_remote_artifact)
RemoteArtifact.objects.bulk_create(remote_artifact_bulk)
for declarative_content in declarative_content_list:
if declarative_content is None:
continue
await out_q.put(declarative_content)
if shutdown:
break
declarative_content_list = []
await out_q.put(None)
def _create_remote_artifact(d_artifact, content_artifact):
return RemoteArtifact(
url=d_artifact.url,
size=d_artifact.artifact.size,
md5=d_artifact.artifact.md5,
sha1=d_artifact.artifact.sha1,
sha224=d_artifact.artifact.sha224,
sha256=d_artifact.artifact.sha256,
sha384=d_artifact.artifact.sha384,
sha512=d_artifact.artifact.sha512,
content_artifact=content_artifact,
remote=d_artifact.remote,
)
content_artifact.artifact = self._stored_model
content_artifact.save()
digests = {f: getattr(self._model, f) for f in Artifact.DIGEST_FIELDS}
try:
with transaction.atomic():
remote_artifact = RemoteArtifact(
url=self.url,
remote=self.remote,
content_artifact=content_artifact,
size=self._model.size,
**digests)
remote_artifact.save()
except IntegrityError:
q_set = RemoteArtifact.objects.filter(
remote=self.remote,
content_artifact=content_artifact)
q_set.update(
url=self.url,
size=self._model.size,
**digests)
content=self.content.stored_model,
artifact=self._stored_model)
content_artifact.save()
except IntegrityError:
content_artifact = ContentArtifact.objects.get(
relative_path=self.relative_path,
content=self.content.stored_model)
if self._stored_model:
content_artifact.artifact = self._stored_model
content_artifact.save()
digests = {f: getattr(self._model, f) for f in Artifact.DIGEST_FIELDS}
try:
with transaction.atomic():
remote_artifact = RemoteArtifact(
url=self.url,
remote=self.remote,
content_artifact=content_artifact,
size=self._model.size,
**digests)
remote_artifact.save()
except IntegrityError:
q_set = RemoteArtifact.objects.filter(
remote=self.remote,
content_artifact=content_artifact)
q_set.update(
url=self.url,
size=self._model.size,
**digests)
artifact=da.artifact,
relative_path=da.relative_path
)
remote_artifact_data = {
'url': da.url,
'size': da.artifact.size,
'md5': da.artifact.md5,
'sha1': da.artifact.sha1,
'sha224': da.artifact.sha224,
'sha256': da.artifact.sha256,
'sha384': da.artifact.sha384,
'sha512': da.artifact.sha512,
'remote': da.remote,
}
new_remote_artifact = RemoteArtifact(
content_artifact=content_artifact, **remote_artifact_data
)
try:
new_remote_artifact.save()
except IntegrityError:
pass
'sha224': declarative_artifact.artifact.sha224,
'sha256': declarative_artifact.artifact.sha256,
'sha384': declarative_artifact.artifact.sha384,
'sha512': declarative_artifact.artifact.sha512,
'remote': declarative_artifact.remote,
}
rel_path = declarative_artifact.relative_path
content_key = str(content_artifact.content.pk) + rel_path
remote_artifact_map[content_key] = remote_artifact_data
for content_artifact in ContentArtifact.objects.bulk_get_or_create(
content_artifact_bulk):
rel_path = content_artifact.relative_path
content_key = str(content_artifact.content.pk) + rel_path
remote_artifact_data = remote_artifact_map.pop(content_key)
new_remote_artifact = RemoteArtifact(
content_artifact=content_artifact, **remote_artifact_data
)
remote_artifact_bulk.append(new_remote_artifact)
RemoteArtifact.objects.bulk_get_or_create(remote_artifact_bulk)
await self._post_save(batch)
for declarative_content in batch:
await out_q.put(declarative_content)
await out_q.put(None)
'sha224': declarative_artifact.artifact.sha224,
'sha256': declarative_artifact.artifact.sha256,
'sha384': declarative_artifact.artifact.sha384,
'sha512': declarative_artifact.artifact.sha512,
'remote': declarative_artifact.remote,
}
remote_artifact_map[content_artifact.relative_path] = remote_artifact_data
for content_artifact in ContentArtifact.objects.bulk_create(content_artifact_bulk):
remote_artifact_data = remote_artifact_map.pop(content_artifact.relative_path)
new_remote_artifact = RemoteArtifact(
content_artifact=content_artifact, **remote_artifact_data
)
remote_artifact_bulk.append(new_remote_artifact)
RemoteArtifact.objects.bulk_create(remote_artifact_bulk)
for declarative_content in declarative_content_list:
if declarative_content is None:
continue
await out_q.put(declarative_content)
if shutdown:
break
declarative_content_list = []
await out_q.put(None)