Skip to content

Commit

Permalink
Revert default OciRegistryStorage to DistributionRegistryStorage
Browse files Browse the repository at this point in the history
reason: the amount of directories is not the important part for efficiency
  • Loading branch information
SgtSilvio committed Jan 20, 2024
1 parent 250fb10 commit 455325c
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 189 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,82 +165,97 @@ internal class TestProject(projectDir: File) {
val registryDir = buildDir.resolve("oci/registries/test")
val blobsDir = registryDir.resolve("blobs")
// @formatter:off
assertTrue(blobsDir.resolve("sha256/1d511796a8d527cf68165c8b95d6606d03c6a30a624d781f8f3682ae14797078").exists())
assertTrue(blobsDir.resolve("sha256/1efc276f4ff952c055dea726cfc96ec6a4fdb8b62d9eed816bd2b788f2860ad7").exists())
assertTrue(blobsDir.resolve("sha256/3ba62f2fe51e3304e4c26340567f70a8dfbd4e0c608a2154e174575544aaa3d9").exists())
assertTrue(blobsDir.resolve("sha256/3e37770490d98f2164cf29b50c7dc209a877d58182ae415540dc99d625e922b0").exists())
assertTrue(blobsDir.resolve("sha256/4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1").exists())
assertTrue(blobsDir.resolve("sha256/8b3654c299169c0f815629af51518c775817d09dd04da9a3bfa510cfa63f12bc").exists())
assertTrue(blobsDir.resolve("sha256/9d19ee268e0d7bcf6716e6658ee1b0384a71d6f2f9aa1ae2085610cf7c7b316f").exists())
assertTrue(blobsDir.resolve("sha256/12cca292b13cb58fadde25af113ddc4ac3b0c5e39ab3f1290a6ba62ec8237afd").exists())
assertTrue(blobsDir.resolve("sha256/18c6d4ab63429acdae46f5bc76e27378afaa44b40a746ae2465b3b4684846ef3").exists())
assertTrue(blobsDir.resolve("sha256/33f5df018e7461c12a9942a1765d92002ac415ceb4cec48020e693c5b9022207").exists())
assertTrue(blobsDir.resolve("sha256/3573c1225d462a8047deb540a10daffee48c949958f8b8842eaebe050daf48bb").exists())
assertTrue(blobsDir.resolve("sha256/45953d25a53f34169be70bf8fc143e66c68cc46d47629b1b76b28be22647c9a9").exists())
assertTrue(blobsDir.resolve("sha256/66b08230f25a80ecfea7a229a734049fc0d9abe01f756f11f922d39357dc487f").exists())
assertTrue(blobsDir.resolve("sha256/92f85d89e7da0f3af0f527e7300cced784d0ba64249b8c376690599d313cb056").exists())
assertTrue(blobsDir.resolve("sha256/a2f2f93da48276873890ac821b3c991d53a7e864791aaf82c39b7863c908b93b").exists())
assertTrue(blobsDir.resolve("sha256/ac9c5946be2a99aca3f2643a8a98f230414662e4ea47e482ccad6bf6b0517657").exists())
assertTrue(blobsDir.resolve("sha256/ac34a2e0269ced3acc355be706239ee0f3f1e73a035c40dd2fac74827164ee53").exists())
assertTrue(blobsDir.resolve("sha256/c18c4e0236f2e8bec242432a19cff1d93bbd422b305e6900809fa4fcf0e07e48").exists())
assertTrue(blobsDir.resolve("sha256/d498448faeaf83b9fa66defd14b2cadc168e211bcb78fb36c748c19b5580b699").exists())
assertTrue(blobsDir.resolve("sha256/d6ae466d10fc5d00afc56a152620df8477ecd22369053f2514d2ea38ad5ed1fb").exists())
assertTrue(blobsDir.resolve("sha256/d73cf48caaac2e45ad76a2a9eb3b311d0e4eb1d804e3d2b9cf075a1fa31e6f92").exists())
assertTrue(blobsDir.resolve("sha256/f2b566cb887b5c06e04f5cd97660a99e73bd52ceb9d72c6db6383ae8470cc4cf").exists())
assertTrue(blobsDir.resolve("sha256/$expectedJarLayerDigest").exists())
assertTrue(blobsDir.resolve("sha256/$expectedConfig1Digest").exists())
assertTrue(blobsDir.resolve("sha256/$expectedConfig2Digest").exists())
assertTrue(blobsDir.resolve("sha256/$expectedManifest1Digest").exists())
assertTrue(blobsDir.resolve("sha256/$expectedManifest2Digest").exists())
assertTrue(blobsDir.resolve("sha256/$expectedIndexDigest").exists())
assertTrue(blobsDir.resolve("sha256/1d/1d511796a8d527cf68165c8b95d6606d03c6a30a624d781f8f3682ae14797078/data").exists())
assertTrue(blobsDir.resolve("sha256/1e/1efc276f4ff952c055dea726cfc96ec6a4fdb8b62d9eed816bd2b788f2860ad7/data").exists())
assertTrue(blobsDir.resolve("sha256/3b/3ba62f2fe51e3304e4c26340567f70a8dfbd4e0c608a2154e174575544aaa3d9/data").exists())
assertTrue(blobsDir.resolve("sha256/3e/3e37770490d98f2164cf29b50c7dc209a877d58182ae415540dc99d625e922b0/data").exists())
assertTrue(blobsDir.resolve("sha256/4f/4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1/data").exists())
assertTrue(blobsDir.resolve("sha256/8b/8b3654c299169c0f815629af51518c775817d09dd04da9a3bfa510cfa63f12bc/data").exists())
assertTrue(blobsDir.resolve("sha256/9d/9d19ee268e0d7bcf6716e6658ee1b0384a71d6f2f9aa1ae2085610cf7c7b316f/data").exists())
assertTrue(blobsDir.resolve("sha256/12/12cca292b13cb58fadde25af113ddc4ac3b0c5e39ab3f1290a6ba62ec8237afd/data").exists())
assertTrue(blobsDir.resolve("sha256/18/18c6d4ab63429acdae46f5bc76e27378afaa44b40a746ae2465b3b4684846ef3/data").exists())
assertTrue(blobsDir.resolve("sha256/33/33f5df018e7461c12a9942a1765d92002ac415ceb4cec48020e693c5b9022207/data").exists())
assertTrue(blobsDir.resolve("sha256/35/3573c1225d462a8047deb540a10daffee48c949958f8b8842eaebe050daf48bb/data").exists())
assertTrue(blobsDir.resolve("sha256/45/45953d25a53f34169be70bf8fc143e66c68cc46d47629b1b76b28be22647c9a9/data").exists())
assertTrue(blobsDir.resolve("sha256/66/66b08230f25a80ecfea7a229a734049fc0d9abe01f756f11f922d39357dc487f/data").exists())
assertTrue(blobsDir.resolve("sha256/92/92f85d89e7da0f3af0f527e7300cced784d0ba64249b8c376690599d313cb056/data").exists())
assertTrue(blobsDir.resolve("sha256/a2/a2f2f93da48276873890ac821b3c991d53a7e864791aaf82c39b7863c908b93b/data").exists())
assertTrue(blobsDir.resolve("sha256/ac/ac9c5946be2a99aca3f2643a8a98f230414662e4ea47e482ccad6bf6b0517657/data").exists())
assertTrue(blobsDir.resolve("sha256/ac/ac34a2e0269ced3acc355be706239ee0f3f1e73a035c40dd2fac74827164ee53/data").exists())
assertTrue(blobsDir.resolve("sha256/c1/c18c4e0236f2e8bec242432a19cff1d93bbd422b305e6900809fa4fcf0e07e48/data").exists())
assertTrue(blobsDir.resolve("sha256/d4/d498448faeaf83b9fa66defd14b2cadc168e211bcb78fb36c748c19b5580b699/data").exists())
assertTrue(blobsDir.resolve("sha256/d6/d6ae466d10fc5d00afc56a152620df8477ecd22369053f2514d2ea38ad5ed1fb/data").exists())
assertTrue(blobsDir.resolve("sha256/d7/d73cf48caaac2e45ad76a2a9eb3b311d0e4eb1d804e3d2b9cf075a1fa31e6f92/data").exists())
assertTrue(blobsDir.resolve("sha256/f2/f2b566cb887b5c06e04f5cd97660a99e73bd52ceb9d72c6db6383ae8470cc4cf/data").exists())
assertTrue(blobsDir.resolve("sha256/${expectedJarLayerDigest.substring(0, 2)}/$expectedJarLayerDigest/data").exists())
assertTrue(blobsDir.resolve("sha256/${expectedConfig1Digest.substring(0, 2)}/$expectedConfig1Digest/data").exists())
assertTrue(blobsDir.resolve("sha256/${expectedConfig2Digest.substring(0, 2)}/$expectedConfig2Digest/data").exists())
assertTrue(blobsDir.resolve("sha256/${expectedManifest1Digest.substring(0, 2)}/$expectedManifest1Digest/data").exists())
assertTrue(blobsDir.resolve("sha256/${expectedManifest2Digest.substring(0, 2)}/$expectedManifest2Digest/data").exists())
assertTrue(blobsDir.resolve("sha256/${expectedIndexDigest.substring(0, 2)}/$expectedIndexDigest/data").exists())
// @formatter:on

val repositoriesDir = registryDir.resolve("repositories")
val testRepositoryDir = repositoriesDir.resolve("example/test")
val testLayersDir = testRepositoryDir.resolve("blobs")
val testLayersDir = testRepositoryDir.resolve("_layers")
// @formatter:off
assertTrue(testLayersDir.resolve("sha256/8b3654c299169c0f815629af51518c775817d09dd04da9a3bfa510cfa63f12bc").exists())
assertTrue(testLayersDir.resolve("sha256/9d19ee268e0d7bcf6716e6658ee1b0384a71d6f2f9aa1ae2085610cf7c7b316f").exists())
assertTrue(testLayersDir.resolve("sha256/92f85d89e7da0f3af0f527e7300cced784d0ba64249b8c376690599d313cb056").exists())
assertTrue(testLayersDir.resolve("sha256/3573c1225d462a8047deb540a10daffee48c949958f8b8842eaebe050daf48bb").exists())
assertTrue(testLayersDir.resolve("sha256/45953d25a53f34169be70bf8fc143e66c68cc46d47629b1b76b28be22647c9a9").exists())
assertTrue(testLayersDir.resolve("sha256/ac9c5946be2a99aca3f2643a8a98f230414662e4ea47e482ccad6bf6b0517657").exists())
assertTrue(testLayersDir.resolve("sha256/ac34a2e0269ced3acc355be706239ee0f3f1e73a035c40dd2fac74827164ee53").exists())
assertTrue(testLayersDir.resolve("sha256/f2b566cb887b5c06e04f5cd97660a99e73bd52ceb9d72c6db6383ae8470cc4cf").exists())
assertTrue(testLayersDir.resolve("sha256/$expectedJarLayerDigest").exists())
assertTrue(testLayersDir.resolve("sha256/$expectedConfig1Digest").exists())
assertTrue(testLayersDir.resolve("sha256/$expectedConfig2Digest").exists())
assertTrue(testLayersDir.resolve("sha256/8b3654c299169c0f815629af51518c775817d09dd04da9a3bfa510cfa63f12bc/link").exists())
assertTrue(testLayersDir.resolve("sha256/9d19ee268e0d7bcf6716e6658ee1b0384a71d6f2f9aa1ae2085610cf7c7b316f/link").exists())
assertTrue(testLayersDir.resolve("sha256/92f85d89e7da0f3af0f527e7300cced784d0ba64249b8c376690599d313cb056/link").exists())
assertTrue(testLayersDir.resolve("sha256/3573c1225d462a8047deb540a10daffee48c949958f8b8842eaebe050daf48bb/link").exists())
assertTrue(testLayersDir.resolve("sha256/45953d25a53f34169be70bf8fc143e66c68cc46d47629b1b76b28be22647c9a9/link").exists())
assertTrue(testLayersDir.resolve("sha256/ac9c5946be2a99aca3f2643a8a98f230414662e4ea47e482ccad6bf6b0517657/link").exists())
assertTrue(testLayersDir.resolve("sha256/ac34a2e0269ced3acc355be706239ee0f3f1e73a035c40dd2fac74827164ee53/link").exists())
assertTrue(testLayersDir.resolve("sha256/f2b566cb887b5c06e04f5cd97660a99e73bd52ceb9d72c6db6383ae8470cc4cf/link").exists())
assertTrue(testLayersDir.resolve("sha256/$expectedJarLayerDigest/link").exists())
assertTrue(testLayersDir.resolve("sha256/$expectedConfig1Digest/link").exists())
assertTrue(testLayersDir.resolve("sha256/$expectedConfig2Digest/link").exists())
// @formatter:on
val testManifestsDir = testRepositoryDir.resolve("manifests")
val testManifestsDir = testRepositoryDir.resolve("_manifests")
val testManifestRevisionsDir = testManifestsDir.resolve("revisions")
// @formatter:off
assertTrue(testManifestsDir.resolve("sha256/$expectedIndexDigest").exists())
assertTrue(testManifestsDir.resolve("sha256/$expectedManifest1Digest").exists())
assertTrue(testManifestsDir.resolve("sha256/$expectedManifest2Digest").exists())
assertTrue(testManifestsDir.resolve("1.0.0").exists())
assertTrue(testManifestsDir.resolve("latest").exists())
assertTrue(testManifestRevisionsDir.resolve("sha256/$expectedIndexDigest/link").exists())
assertTrue(testManifestRevisionsDir.resolve("sha256/$expectedManifest1Digest/link").exists())
assertTrue(testManifestRevisionsDir.resolve("sha256/$expectedManifest2Digest/link").exists())
// @formatter:on
val testTagsDir = testManifestsDir.resolve("tags")
val test1TagDir = testTagsDir.resolve("1.0.0")
// @formatter:off
assertTrue(test1TagDir.resolve("current/link").exists())
assertTrue(test1TagDir.resolve("index/sha256/$expectedIndexDigest/link").exists())
// @formatter:on
val testLatestTagDir = testTagsDir.resolve("latest")
// @formatter:off
assertTrue(testLatestTagDir.resolve("current/link").exists())
assertTrue(testLatestTagDir.resolve("index/sha256/$expectedIndexDigest/link").exists())
// @formatter:on

val hivemqRepositoryDir = repositoriesDir.resolve("hivemq/hivemq4")
val hivemqLayersDir = hivemqRepositoryDir.resolve("blobs")
val hivemqLayersDir = hivemqRepositoryDir.resolve("_layers")
// @formatter:off
assertTrue(hivemqLayersDir.resolve("sha256/1d511796a8d527cf68165c8b95d6606d03c6a30a624d781f8f3682ae14797078/link").exists())
assertTrue(hivemqLayersDir.resolve("sha256/1efc276f4ff952c055dea726cfc96ec6a4fdb8b62d9eed816bd2b788f2860ad7/link").exists())
assertTrue(hivemqLayersDir.resolve("sha256/3ba62f2fe51e3304e4c26340567f70a8dfbd4e0c608a2154e174575544aaa3d9/link").exists())
assertTrue(hivemqLayersDir.resolve("sha256/3e37770490d98f2164cf29b50c7dc209a877d58182ae415540dc99d625e922b0/link").exists())
assertTrue(hivemqLayersDir.resolve("sha256/4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1/link").exists())
assertTrue(hivemqLayersDir.resolve("sha256/12cca292b13cb58fadde25af113ddc4ac3b0c5e39ab3f1290a6ba62ec8237afd/link").exists())
assertTrue(hivemqLayersDir.resolve("sha256/18c6d4ab63429acdae46f5bc76e27378afaa44b40a746ae2465b3b4684846ef3/link").exists())
assertTrue(hivemqLayersDir.resolve("sha256/33f5df018e7461c12a9942a1765d92002ac415ceb4cec48020e693c5b9022207/link").exists())
assertTrue(hivemqLayersDir.resolve("sha256/66b08230f25a80ecfea7a229a734049fc0d9abe01f756f11f922d39357dc487f/link").exists())
assertTrue(hivemqLayersDir.resolve("sha256/a2f2f93da48276873890ac821b3c991d53a7e864791aaf82c39b7863c908b93b/link").exists())
assertTrue(hivemqLayersDir.resolve("sha256/d6ae466d10fc5d00afc56a152620df8477ecd22369053f2514d2ea38ad5ed1fb/link").exists())
assertTrue(hivemqLayersDir.resolve("sha256/d73cf48caaac2e45ad76a2a9eb3b311d0e4eb1d804e3d2b9cf075a1fa31e6f92/link").exists())
// @formatter:on
val hivemqManifestsDir = hivemqRepositoryDir.resolve("_manifests")
val hivemqManifestRevisionsDir = hivemqManifestsDir.resolve("revisions")
// @formatter:off
assertTrue(hivemqLayersDir.resolve("sha256/1d511796a8d527cf68165c8b95d6606d03c6a30a624d781f8f3682ae14797078").exists())
assertTrue(hivemqLayersDir.resolve("sha256/1efc276f4ff952c055dea726cfc96ec6a4fdb8b62d9eed816bd2b788f2860ad7").exists())
assertTrue(hivemqLayersDir.resolve("sha256/3ba62f2fe51e3304e4c26340567f70a8dfbd4e0c608a2154e174575544aaa3d9").exists())
assertTrue(hivemqLayersDir.resolve("sha256/3e37770490d98f2164cf29b50c7dc209a877d58182ae415540dc99d625e922b0").exists())
assertTrue(hivemqLayersDir.resolve("sha256/4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1").exists())
assertTrue(hivemqLayersDir.resolve("sha256/12cca292b13cb58fadde25af113ddc4ac3b0c5e39ab3f1290a6ba62ec8237afd").exists())
assertTrue(hivemqLayersDir.resolve("sha256/18c6d4ab63429acdae46f5bc76e27378afaa44b40a746ae2465b3b4684846ef3").exists())
assertTrue(hivemqLayersDir.resolve("sha256/33f5df018e7461c12a9942a1765d92002ac415ceb4cec48020e693c5b9022207").exists())
assertTrue(hivemqLayersDir.resolve("sha256/66b08230f25a80ecfea7a229a734049fc0d9abe01f756f11f922d39357dc487f").exists())
assertTrue(hivemqLayersDir.resolve("sha256/a2f2f93da48276873890ac821b3c991d53a7e864791aaf82c39b7863c908b93b").exists())
assertTrue(hivemqLayersDir.resolve("sha256/d6ae466d10fc5d00afc56a152620df8477ecd22369053f2514d2ea38ad5ed1fb").exists())
assertTrue(hivemqLayersDir.resolve("sha256/d73cf48caaac2e45ad76a2a9eb3b311d0e4eb1d804e3d2b9cf075a1fa31e6f92").exists())
assertTrue(hivemqManifestRevisionsDir.resolve("sha256/c18c4e0236f2e8bec242432a19cff1d93bbd422b305e6900809fa4fcf0e07e48/link").exists())
assertTrue(hivemqManifestRevisionsDir.resolve("sha256/d498448faeaf83b9fa66defd14b2cadc168e211bcb78fb36c748c19b5580b699/link").exists())
// @formatter:on
val hivemqManifestsDir = hivemqRepositoryDir.resolve("manifests")
val hivemqTagDir = hivemqManifestsDir.resolve("tags/4.16.0")
// @formatter:off
assertTrue(hivemqManifestsDir.resolve("sha256/c18c4e0236f2e8bec242432a19cff1d93bbd422b305e6900809fa4fcf0e07e48").exists())
assertTrue(hivemqManifestsDir.resolve("sha256/d498448faeaf83b9fa66defd14b2cadc168e211bcb78fb36c748c19b5580b699").exists())
assertTrue(hivemqManifestsDir.resolve("4.16.0").exists())
assertTrue(hivemqTagDir.resolve("current/link").exists())
assertTrue(hivemqTagDir.resolve("index/sha256/d498448faeaf83b9fa66defd14b2cadc168e211bcb78fb36c748c19b5580b699/link").exists())
// @formatter:on
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import io.github.sgtsilvio.gradle.oci.platform.Platform
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.tasks.OutputDirectory
import java.io.File
import java.io.IOException
import java.nio.file.FileAlreadyExistsException
import java.nio.file.Path
import java.nio.file.StandardOpenOption
Expand Down Expand Up @@ -121,3 +122,10 @@ abstract class DistributionRegistryDataTask : OciImagesInputTask() {
}
}
}

internal fun Path.ensureEmptyDirectory(): Path {
if (!toFile().deleteRecursively()) {
throw IOException("$this could not be deleted")
}
return createDirectories()
}
Loading

0 comments on commit 455325c

Please sign in to comment.