make sure that all pushed data is actually written

This commit is contained in:
Ilion Beyst 2022-06-30 20:28:37 +02:00
parent d7e4a1fd5c
commit 4d1c0a3289

View file

@ -227,8 +227,8 @@ async fn patch_upload(
.await .await
.unwrap(); .unwrap();
while let Some(Ok(chunk)) = stream.next().await { while let Some(Ok(chunk)) = stream.next().await {
let n_bytes = file.write(&chunk).await.unwrap(); file.write_all(&chunk).await.unwrap();
len += n_bytes; len += chunk.len();
} }
Ok(Response::builder() Ok(Response::builder()
@ -270,9 +270,10 @@ async fn put_upload(
.unwrap(); .unwrap();
while let Some(Ok(chunk)) = stream.next().await { while let Some(Ok(chunk)) = stream.next().await {
let n_bytes = file.write(&chunk).await.unwrap(); file.write_all(&chunk).await.unwrap();
_len += n_bytes; _len += chunk.len();
} }
let digest = params.digest.strip_prefix("sha256:").unwrap(); let digest = params.digest.strip_prefix("sha256:").unwrap();
// TODO: check the digest // TODO: check the digest
let target_path = PathBuf::from(REGISTRY_PATH).join("sha256").join(&digest); let target_path = PathBuf::from(REGISTRY_PATH).join("sha256").join(&digest);