diff options
Diffstat (limited to 'planetwars-server/src')
-rw-r--r-- | planetwars-server/src/modules/registry.rs | 4 |
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(); |