From b90b3d3635f57bb84450d90544df536bf58e8588 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Fri, 17 Jun 2022 19:01:40 +0200 Subject: store blobs in sha256 directory --- planetwars-server/src/modules/registry.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'planetwars-server') diff --git a/planetwars-server/src/modules/registry.rs b/planetwars-server/src/modules/registry.rs index d63621a..d10532a 100644 --- a/planetwars-server/src/modules/registry.rs +++ b/planetwars-server/src/modules/registry.rs @@ -62,7 +62,7 @@ async fn blob_check( Path((_repository_name, raw_digest)): Path<(String, String)>, ) -> impl IntoResponse { let digest = raw_digest.strip_prefix("sha256:").unwrap(); - let blob_path = PathBuf::from(REGISTRY_PATH).join(&digest); + let blob_path = PathBuf::from(REGISTRY_PATH).join("sha256").join(&digest); if blob_path.exists() { StatusCode::OK } else { @@ -162,9 +162,9 @@ async fn put_handler( } let digest = params.digest.strip_prefix("sha256:").unwrap(); // TODO: check the digest - let target_path = PathBuf::from(REGISTRY_PATH).join(&digest); + let target_path = PathBuf::from(REGISTRY_PATH).join("sha256").join(&digest); tokio::fs::rename(&upload_path, &target_path).await.unwrap(); - println!("DIGEST {}", digest); + Response::builder() .status(StatusCode::CREATED) .header( @@ -182,7 +182,9 @@ async fn put_manifest( Path((repository_name, reference)): Path<(String, String)>, mut stream: BodyStream, ) -> impl IntoResponse { - let repository_dir = PathBuf::from(REGISTRY_PATH).join(&repository_name); + let repository_dir = PathBuf::from(REGISTRY_PATH) + .join("manifests") + .join(&repository_name); tokio::fs::create_dir_all(&repository_dir).await.unwrap(); -- cgit v1.2.3