refactor(nix-compat/store_path): use nixbase32::decode_fixed

Change-Id: I81471ee57920aa8fa889fb00c7903cdc570af9c5
Reviewed-on: https://cl.tvl.fyi/c/depot/+/9863
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
This commit is contained in:
edef 2023-10-27 13:21:37 +00:00
parent 50aa74a59c
commit b1ad94cc9a

View file

@ -203,10 +203,8 @@ impl<'a> StorePathRef<'a> {
Err(Error::InvalidLength)?
}
let digest = match nixbase32::decode(&s[..ENCODED_DIGEST_SIZE]) {
Ok(decoded) => decoded,
Err(decoder_error) => return Err(Error::InvalidHashEncoding(decoder_error)),
};
let digest = nixbase32::decode_fixed(&s[..ENCODED_DIGEST_SIZE])
.map_err(Error::InvalidHashEncoding)?;
if s[ENCODED_DIGEST_SIZE] != b'-' {
return Err(Error::MissingDash);