Skip to content

Commit

Permalink
draft/wip
Browse files Browse the repository at this point in the history
  • Loading branch information
git-hyagi committed Apr 17, 2024
1 parent 2a43e09 commit 4036b14
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions pulp_container/app/tasks/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,20 @@ def get_or_create_blob(layer_json, manifest, path):
blob.touch()
except Blob.DoesNotExist:
layer_file_name = os.path.join(path, layer_json["digest"][7:])
layer_artifact = Artifact.init_and_validate(layer_file_name)
layer_artifact.save()
blob = Blob(digest=layer_json["digest"])
blob.save()
ContentArtifact(
artifact=layer_artifact, content=blob, relative_path=layer_json["digest"]
).save()
if layer_json["mediaType"] != MEDIA_TYPE.CONFIG_BLOB_OCI:
BlobManifest(manifest=manifest, manifest_blob=blob).save()
if layer_json["mediaType"] in [MEDIA_TYPE.CONFIG_BLOB_OCI, MEDIA_TYPE.CONFIG_BLOB]:
with open(layer_file_name, "r") as content_file:
raw_data = content_file.read()
blob.data = raw_data
blob.save()
else:
layer_artifact = Artifact.init_and_validate(layer_file_name)
layer_artifact.save()
ContentArtifact(
artifact=layer_artifact, content=blob, relative_path=layer_json["digest"]
).save()
BlobManifest(manifest=manifest, manifest_blob=blob).save()
return blob


Expand Down

0 comments on commit 4036b14

Please sign in to comment.