Skip to content

Commit

Permalink
Only store necessary layers in Oci/DistributionRegistryDataTask
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtSilvio committed Jan 20, 2024
1 parent 6a1e6ab commit ad49bf9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ abstract class DistributionRegistryDataTask : OciImagesInputTask() {
val registryDataDirectory = registryDataDirectory.get().asFile.toPath().ensureEmptyDirectory()
val blobsDirectory = registryDataDirectory.resolve("blobs").createDirectory()
val repositoriesDirectory = registryDataDirectory.resolve("repositories").createDirectory()

for ((digest, layer) in digestToLayer) {
blobsDirectory.resolveDigestDataFile(digest).createLinkPointingTo(layer.toPath())
}
val layerDigests = mutableSetOf<OciDigest>()
for ((resolvedComponent, imageReferences) in resolvedComponentToImageReferences) {
writeImage(resolvedComponent, imageReferences, blobsDirectory, repositoriesDirectory)
writeImage(resolvedComponent, imageReferences, blobsDirectory, repositoriesDirectory, layerDigests)
}
for (digest in layerDigests) {
blobsDirectory.resolveDigestDataFile(digest).createLinkPointingTo(digestToLayer[digest]!!.toPath())
}
}

Expand All @@ -40,15 +40,17 @@ abstract class DistributionRegistryDataTask : OciImagesInputTask() {
imageReferences: Set<OciImageReference>,
blobsDirectory: Path,
repositoriesDirectory: Path,
layerDigests: MutableSet<OciDigest>,
) {
val manifests = mutableListOf<Pair<Platform, OciDataDescriptor>>()
val blobDigests = mutableSetOf<OciDigest>()
for (platform in resolvedComponent.platforms) {
val bundlesForPlatform = resolvedComponent.collectBundlesForPlatform(platform).map { it.bundle }
for (bundle in bundlesForPlatform) {
for (layer in bundle.layers) {
layer.descriptor?.let {
blobDigests += it.digest
layer.descriptor?.let { (_, digest) ->
layerDigests += digest
blobDigests += digest
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ abstract class OciRegistryDataTask : OciImagesInputTask() {
val registryDataDirectory = registryDataDirectory.get().asFile.toPath().ensureEmptyDirectory()
val blobsDirectory = registryDataDirectory.resolve("blobs").createDirectory()
val repositoriesDirectory = registryDataDirectory.resolve("repositories").createDirectory()

for ((digest, layer) in digestToLayer) {
blobsDirectory.resolveDigestFile(digest).createLinkPointingTo(layer.toPath())
}
val layerDigests = mutableSetOf<OciDigest>()
for ((resolvedComponent, imageReferences) in resolvedComponentToImageReferences) {
writeImage(resolvedComponent, imageReferences, blobsDirectory, repositoriesDirectory)
writeImage(resolvedComponent, imageReferences, blobsDirectory, repositoriesDirectory, layerDigests)
}
for (digest in layerDigests) {
blobsDirectory.resolveDigestFile(digest).createLinkPointingTo(digestToLayer[digest]!!.toPath())
}
}

Expand All @@ -41,15 +41,17 @@ abstract class OciRegistryDataTask : OciImagesInputTask() {
imageReferences: Set<OciImageReference>,
blobsDirectory: Path,
repositoriesDirectory: Path,
layerDigests: MutableSet<OciDigest>,
) {
val manifests = mutableListOf<Pair<Platform, OciDataDescriptor>>()
val blobDigests = mutableSetOf<OciDigest>()
for (platform in resolvedComponent.platforms) {
val bundlesForPlatform = resolvedComponent.collectBundlesForPlatform(platform).map { it.bundle }
for (bundle in bundlesForPlatform) {
for (layer in bundle.layers) {
layer.descriptor?.let {
blobDigests += it.digest
layer.descriptor?.let { (_, digest) ->
layerDigests += digest
blobDigests += digest
}
}
}
Expand Down

0 comments on commit ad49bf9

Please sign in to comment.