From 4d1c0a3289a295ea27eea51ec0a91c4229a92edc Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Thu, 30 Jun 2022 20:28:37 +0200 Subject: make sure that all pushed data is actually written --- planetwars-server/src/modules/registry.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'planetwars-server') diff --git a/planetwars-server/src/modules/registry.rs b/planetwars-server/src/modules/registry.rs index 346f5d9..7adb764 100644 --- a/planetwars-server/src/modules/registry.rs +++ b/planetwars-server/src/modules/registry.rs @@ -227,8 +227,8 @@ async fn patch_upload( .await .unwrap(); while let Some(Ok(chunk)) = stream.next().await { - let n_bytes = file.write(&chunk).await.unwrap(); - len += n_bytes; + file.write_all(&chunk).await.unwrap(); + len += chunk.len(); } Ok(Response::builder() @@ -270,9 +270,10 @@ async fn put_upload( .unwrap(); while let Some(Ok(chunk)) = stream.next().await { - let n_bytes = file.write(&chunk).await.unwrap(); - _len += n_bytes; + file.write_all(&chunk).await.unwrap(); + _len += chunk.len(); } + let digest = params.digest.strip_prefix("sha256:").unwrap(); // TODO: check the digest let target_path = PathBuf::from(REGISTRY_PATH).join("sha256").join(&digest); -- cgit v1.2.3