diff --git a/Makefile b/Makefile index 7e767da..181fb4b 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,16 @@ SRC=$(shell find . -name \*.rs | grep -v "^./target") - -.PHONY: debug -debug: - cargo build +PREFIX?=/usr/local +ROOT_SBINDIR?=$(PREFIX)/sbin +INSTALL=install .PHONY: release release: cargo build --release +.PHONY: debug +debug: + cargo build + .PHONY: check check: RUST_BACKTRACE=1 cargo test -- --nocapture @@ -24,3 +27,6 @@ fmt: .PHONY: clean clean: -cargo clean + +install: + $(INSTALL) -m0755 -D target/release/puzzlefs -t $(ROOT_SBINDIR) diff --git a/puzzlefs-lib/src/format/types.rs b/puzzlefs-lib/src/format/types.rs index c472927..da1d276 100644 --- a/puzzlefs-lib/src/format/types.rs +++ b/puzzlefs-lib/src/format/types.rs @@ -794,10 +794,8 @@ impl Serialize for Digest { impl TryFrom<&str> for Digest { type Error = FromHexError; fn try_from(s: &str) -> std::result::Result { - let digest = hex::decode(s)?; - let digest: [u8; SHA256_BLOCK_SIZE] = digest - .try_into() - .map_err(|_| FromHexError::InvalidStringLength)?; + let mut digest: [u8; SHA256_BLOCK_SIZE] = [0; SHA256_BLOCK_SIZE]; + hex::decode_to_slice(s, &mut digest)?; Ok(Digest(digest)) } }