pub fn check(&self, tmpfile: &mut TmpFile) -> Result<Checksum> {
        let filename = tmpfile.filename();
        let shasum   = self.shasum(filename)
            .ok_or_else(|| anyhow!("Couldn't find shasum for {}", filename))?;

        let mut file   = tmpfile.handle()?;
        let mut hasher = Sha256::new();

        io::copy(&mut file, &mut hasher)?;

        let hash = hasher.finalize();

        let res = if hex::encode(hash) == shasum {
            Checksum::OK
        }
        else {
            Checksum::Bad
        };

        Ok(res)
    }
// Check the shasum of the specified file
Check the shasum of the specified file
Check the shasum of the specified file
pub fn check(&self, tmpfile: &mut TmpFile) -> Result<Checksum> {
        let filename = tmpfile.filename();
        let shasum   = self.shasum(filename)
            .ok_or_else(|| anyhow!("Couldn't find shasum for {}", filename))?;
        let mut file   = tmpfile.handle()?;
        let mut hasher = Sha256::new();
        io::copy(&mut file, &mut hasher)?;
        let hash = hasher.finalize();
        let res = if hex::encode(hash) == shasum {
            Checksum::OK
        }
        else {
            Checksum::Bad
        };
        Ok(res)
    }
pub fn check ( & self , tmpfile : & mut TmpFile ) -> Result < Checksum > { let filename = tmpfile . filename ( ) ; let shasum = self . shasum ( filename ) . ok_or_else ( | | anyhow ! ( " " filename ) ) ? ; let mut file = tmpfile . handle ( ) ? ; let mut hasher = Sha256 :: new ( ) ; io :: copy ( & mut file , & mut hasher ) ? ; let hash = hasher . finalize ( ) ; let res = if hex :: encode ( hash ) == shasum { Checksum :: OK } else { Checksum :: Bad } ; Ok ( res ) }
Check the shasum of the specified file
Check the shasum of the specified file
&self
tmpfile
&mut TmpFile
&self
tmpfile
&mut TmpFile