Implement table gc, currently for block_ref and version only

This commit is contained in:
Alex Auvolat
2021-03-12 19:57:37 +01:00
parent f4aad8fe6e
commit c475471e7a
14 changed files with 301 additions and 57 deletions
+1 -3
View File
@@ -225,9 +225,7 @@ async fn read_and_put_blocks(
let data_md5sum = md5hasher.finalize();
let data_sha256sum = sha256hasher.result();
let mut hash = [0u8; 32];
hash.copy_from_slice(&data_sha256sum[..]);
let data_sha256sum = Hash::from(hash);
let data_sha256sum = Hash::try_from(&data_sha256sum[..]).unwrap();
Ok((total_size, data_md5sum, data_sha256sum))
}
+2 -6
View File
@@ -106,12 +106,8 @@ pub async fn check_signature(
} else {
let bytes = hex::decode(authorization.content_sha256)
.ok_or_bad_request("Invalid content sha256 hash")?;
let mut hash = [0u8; 32];
if bytes.len() != 32 {
return Err(Error::BadRequest(format!("Invalid content sha256 hash")));
}
hash.copy_from_slice(&bytes[..]);
Some(Hash::from(hash))
Some(Hash::try_from(&bytes[..])
.ok_or(Error::BadRequest(format!("Invalid content sha256 hash")))?)
};
Ok((key, content_sha256))