/// Before storing chunk data into blob cache file. We have cook the raw chunk from
/// backend a bit per as to the chunk description as blob cache always saves plain data
/// into cache file rather than compressed.
/// An inside trick is that it tries to directly save data into caller's buffer.
Before storing chunk data into blob cache file. We have cook the raw chunk from
backend a bit per as to the chunk description as blob cache always saves plain data
into cache file rather than compressed.
An inside trick is that it tries to directly save data into caller's buffer.
Before storing chunk data into blob cache file . We have cook the raw chunk from backend a bit per as to the chunk description as blob cache always saves plain data into cache file rather than compressed . An inside trick is that it tries to directly save data into caller ' s buffer .
fn process_raw_chunk(
        &self,
        cki: &dyn RafsChunkInfo,
        raw_chunk: &[u8],
        raw_stream: Option<File>,
        chunk: &mut [u8],
        need_decompress: bool,
        need_validate: bool,
    ) -> Result<usize> {
        if need_decompress {
            compress::decompress(raw_chunk, raw_stream, chunk, self.compressor()).map_err(|e| {
                error!("failed to decompress chunk: {}", e);
                e
            })?;
        } else if raw_chunk.as_ptr() != chunk.as_ptr() {
            // Sometimes, caller directly put data into consumer provided buffer.
            // Then we don't have to copy data between slices.
            chunk.copy_from_slice(raw_chunk);
        }
        let d_size = cki.decompress_size() as usize;
        if chunk.len() != d_size {
            return Err(eio!());
        }
        if need_validate && !digest_check(chunk, &cki.block_id(), self.digester()) {
            return Err(eio!());
        }
        Ok(chunk.len())
    }
fn process_raw_chunk ( & self , cki : & dyn RafsChunkInfo , raw_chunk : & [ u8 ] , raw_stream : Option < File > , chunk : & mut [ u8 ] , need_decompress : bool , need_validate : bool , ) -> Result < usize > { if need_decompress { compress :: decompress ( raw_chunk , raw_stream , chunk , self . compressor ( ) ) . map_err ( | e | { error ! ( " " e ) ; e } ) ? ; } else if raw_chunk . as_ptr ( ) != chunk . as_ptr ( ) { // Sometimes, caller directly put data into consumer provided buffer. // Then we don't have to copy data between slices. chunk . copy_from_slice ( raw_chunk ) ; } let d_size = cki . decompress_size ( ) as usize ; if chunk . len ( ) != d_size { return Err ( eio ! ( ) ) ; } if need_validate && ! digest_check ( chunk , & cki . block_id ( ) , self . digester ( ) ) { return Err ( eio ! ( ) ) ; } Ok ( chunk . len ( ) ) }
Before storing chunk data into blob cache file.
Before storing chunk data into blob cache file .
&self
cki
&dyn RafsChunkInfo
raw_chunk
&[u8]
raw_stream
Option<File>
chunk
&mut [u8]
need_decompress
bool
need_validate
bool