aboutsummaryrefslogtreecommitdiff
path: root/planetwars-server/src
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-08-30 19:35:29 +0200
committerIlion Beyst <ilion.beyst@gmail.com>2022-08-30 19:35:29 +0200
commitd95eedcc83f8d07a49c25c5240beb8a0105d877a (patch)
tree2142dbd1b3c454b600d91ee1ace01bbf0cb6731d /planetwars-server/src
parente8e353192c97b32396acd830e08de28d365034f0 (diff)
downloadplanetwars.dev-d95eedcc83f8d07a49c25c5240beb8a0105d877a.tar.xz
planetwars.dev-d95eedcc83f8d07a49c25c5240beb8a0105d877a.zip
registry: ensure that files have been closed before calculating checksums
Diffstat (limited to 'planetwars-server/src')
-rw-r--r--planetwars-server/src/modules/registry.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/planetwars-server/src/modules/registry.rs b/planetwars-server/src/modules/registry.rs
index 297404a..4a79d59 100644
--- a/planetwars-server/src/modules/registry.rs
+++ b/planetwars-server/src/modules/registry.rs
@@ -300,8 +300,10 @@ async fn put_upload(
while let Some(Ok(chunk)) = stream.next().await {
file.write_all(&chunk).await.unwrap();
}
- file.flush().await.unwrap();
let range_end = last_byte_pos(&file).await.unwrap();
+ // Close the file to ensure all data has been flushed to the kernel.
+ // If we don't do this, calculating the checksum can fail.
+ std::mem::drop(file);
let expected_digest = params.digest.strip_prefix("sha256:").unwrap();
let digest = file_sha256_digest(&upload_path).unwrap();