/// Verify checksum of a managed file
Verify checksum of a managed file
Verify checksum of a managed file
pub fn validate_checksum(&self, path: &Path) -> result::Result<bool, OpenReadError> {
        let reader = self.directory.open_read(path)?;
        let (footer, data) =
            Footer::extract_footer(reader).map_err(|io_error| OpenReadError::IoError {
                io_error,
                filepath: path.to_path_buf(),
            })?;
        let bytes = data
            .read_bytes()
            .map_err(|io_error| OpenReadError::IoError {
                filepath: path.to_path_buf(),
                io_error,
            })?;
        let mut hasher = Hasher::new();
        hasher.update(bytes.as_slice());
        let crc = hasher.finalize();
        Ok(footer.crc() == crc)
    }
pub fn validate_checksum ( & self , path : & Path ) -> result :: Result < bool , OpenReadError > { let reader = self . directory . open_read ( path ) ? ; let ( footer , data ) = Footer :: extract_footer ( reader ) . map_err ( | io_error | OpenReadError :: IoError { io_error , filepath : path . to_path_buf ( ) , } ) ? ; let bytes = data . read_bytes ( ) . map_err ( | io_error | OpenReadError :: IoError { filepath : path . to_path_buf ( ) , io_error , } ) ? ; let mut hasher = Hasher :: new ( ) ; hasher . update ( bytes . as_slice ( ) ) ; let crc = hasher . finalize ( ) ; Ok ( footer . crc ( ) == crc ) }
Verify checksum of a managed file
Verify checksum of a managed file
&self
path
&Path