// Load number of chunks in file from metadata
Load number of chunks in file from metadata
Load number of chunks in file from metadata
pub fn load_meta(
    prefix: &str,
    hash: &str,
) -> Result<(u32, Option<u64>, Option<String>), ProtocolError> {
    let mut data = vec![];
    let meta_path = Path::new(&format!("{}/storage", prefix))
        .join(hash)
        .join("meta");
    File::open(meta_path)
        .map_err(|err| ProtocolError::StorageError {
            action: format!("open {} metadata file", hash),
            err,
        })?
        .read_to_end(&mut data)
        .map_err(|err| ProtocolError::StorageError {
            action: format!("read {} metadata file", hash),
            err,
        })?;
    let metadata: Meta = de::from_slice(&data).map_err(|err| {
        ProtocolError::StorageParseError(format!("Unable to parse metadata for {}: {}", hash, err))
    })?;
    Ok((metadata.num_chunks, metadata.chunk_size, metadata.file_path))
}
pub fn load_meta ( prefix : & str , hash : & str , ) -> Result < ( u32 , Option < u64 > , Option < String > ) , ProtocolError > { let mut data = vec ! [ ] ; let meta_path = Path :: new ( & format ! ( " " prefix ) ) . join ( hash ) . join ( " " ) ; File :: open ( meta_path ) . map_err ( | err | ProtocolError :: StorageError { action : format ! ( " " hash ) , err , } ) ? . read_to_end ( & mut data ) . map_err ( | err | ProtocolError :: StorageError { action : format ! ( " " hash ) , err , } ) ? ; let metadata : Meta = de :: from_slice ( & data ) . map_err ( | err | { ProtocolError :: StorageParseError ( format ! ( " " hash err ) ) } ) ? ; Ok ( ( metadata . num_chunks , metadata . chunk_size , metadata . file_path ) ) }
Load number of chunks in file from metadata
Load number of chunks in file from metadata
prefix
&str
hash
&str