fn check_digest(&mut self, status: &mut dyn StatusBackend) -> Result<()> {
        if self.checked_digest {
            return Ok(());
        }

        // Do a quick and dirty check first and ignore errors.
        if let Some(info) = self.index.get(digest::DIGEST_NAME) {
            if let Ok(d) = get_file(
                &mut self.tar_data,
                digest::DIGEST_NAME,
                info.offset,
                info.length as usize,
                status,
            ) {
                if let Ok(d) = String::from_utf8(d) {
                    if let Ok(d) = DigestData::from_str(&d) {
                        if self.cached_digest == d {
                            // We managed to pull some data that match the digest.
                            // We can be quite confident that the bundle is what we expect it to be.
                            self.checked_digest = true;
                            return Ok(());
                        }
                    }
                }
            }
        }

        // The quick check failed. Try to pull all data to make sure that it wasn't a network
        // error or that the redirect url hasn't been updated.
        let (digest_text, _index, redirect_url) = get_everything(&self.url, status)?;

        let current_digest =
            ctry!(DigestData::from_str(&digest_text); "bad SHA256 digest from bundle");

        if self.cached_digest != current_digest {
            // Crap! The backend isn't what we thought it was. Rewrite the
            // digest file so that next time we'll start afresh.

            file_create_write(&self.digest_path, |f| {
                writeln!(f, "{}", current_digest.to_string())
            })?;
            bail!("backend digest changed; rerun tectonic to use updated information");
        }

        if self.redirect_url != redirect_url {
            // The redirect url has changed, let's update it.
            let redirect_path = make_txt_path(&self.redirect_base, &digest_text);
            file_create_write(&redirect_path, |f| f.write_all(redirect_url.as_bytes()))?;

            self.redirect_url = redirect_url;
        }

        // Index should've changed as the digest hasn't.

        // Phew, the backend hasn't changed. Don't check again.
        self.checked_digest = true;
        Ok(())
    }
/// If we're going to make a request of the backend, we should check that
/// its digest is what we expect. If not, we do a lame thing where we
/// error out but set things up so that things should succeed if the
/// program is re-run. Exactly the lame TeX user experience that I've been
/// trying to avoid!
If we're going to make a request of the backend, we should check that
its digest is what we expect. If not, we do a lame thing where we
error out but set things up so that things should succeed if the
program is re-run. Exactly the lame TeX user experience that I've been
trying to avoid!
If we ' re going to make a request of the backend we should check that its digest is what we expect . If not we do a lame thing where we error out but set things up so that things should succeed if the program is re - run . Exactly the lame TeX user experience that I ' ve been trying to avoid!
fn check_digest(&mut self, status: &mut dyn StatusBackend) -> Result<()> {
        if self.checked_digest {
            return Ok(());
        }
        // Do a quick and dirty check first and ignore errors.
        if let Some(info) = self.index.get(digest::DIGEST_NAME) {
            if let Ok(d) = get_file(
                &mut self.tar_data,
                digest::DIGEST_NAME,
                info.offset,
                info.length as usize,
                status,
            ) {
                if let Ok(d) = String::from_utf8(d) {
                    if let Ok(d) = DigestData::from_str(&d) {
                        if self.cached_digest == d {
                            // We managed to pull some data that match the digest.
                            // We can be quite confident that the bundle is what we expect it to be.
                            self.checked_digest = true;
                            return Ok(());
                        }
                    }
                }
            }
        }
        // The quick check failed. Try to pull all data to make sure that it wasn't a network
        // error or that the redirect url hasn't been updated.
        let (digest_text, _index, redirect_url) = get_everything(&self.url, status)?;
        let current_digest =
            ctry!(DigestData::from_str(&digest_text); "bad SHA256 digest from bundle");
        if self.cached_digest != current_digest {
            // Crap! The backend isn't what we thought it was. Rewrite the
            // digest file so that next time we'll start afresh.
            file_create_write(&self.digest_path, |f| {
                writeln!(f, "{}", current_digest.to_string())
            })?;
            bail!("backend digest changed; rerun tectonic to use updated information");
        }
        if self.redirect_url != redirect_url {
            // The redirect url has changed, let's update it.
            let redirect_path = make_txt_path(&self.redirect_base, &digest_text);
            file_create_write(&redirect_path, |f| f.write_all(redirect_url.as_bytes()))?;
            self.redirect_url = redirect_url;
        }
        // Index should've changed as the digest hasn't.
        // Phew, the backend hasn't changed. Don't check again.
        self.checked_digest = true;
        Ok(())
    }
fn check_digest ( & mut self , status : & mut dyn StatusBackend ) -> Result < ( ) > { if self . checked_digest { return Ok ( ( ) ) ; } // Do a quick and dirty check first and ignore errors. if let Some ( info ) = self . index . get ( digest :: DIGEST_NAME ) { if let Ok ( d ) = get_file ( & mut self . tar_data , digest :: DIGEST_NAME , info . offset , info . length as usize , status , ) { if let Ok ( d ) = String :: from_utf8 ( d ) { if let Ok ( d ) = DigestData :: from_str ( & d ) { if self . cached_digest == d { // We managed to pull some data that match the digest. // We can be quite confident that the bundle is what we expect it to be. self . checked_digest = true ; return Ok ( ( ) ) ; } } } } } // The quick check failed. Try to pull all data to make sure that it wasn't a network // error or that the redirect url hasn't been updated. let ( digest_text , _index , redirect_url ) = get_everything ( & self . url , status ) ? ; let current_digest = ctry ! ( DigestData from_str ( digest_text ) " " ) ; if self . cached_digest != current_digest { // Crap! The backend isn't what we thought it was. Rewrite the // digest file so that next time we'll start afresh. file_create_write ( & self . digest_path , | f | { writeln ! ( f " " current_digest to_string ( ) ) } ) ? ; bail ! ( " " ) ; } if self . redirect_url != redirect_url { // The redirect url has changed, let's update it. let redirect_path = make_txt_path ( & self . redirect_base , & digest_text ) ; file_create_write ( & redirect_path , | f | f . write_all ( redirect_url . as_bytes ( ) ) ) ? ; self . redirect_url = redirect_url ; } // Index should've changed as the digest hasn't. // Phew, the backend hasn't changed. Don't check again. self . checked_digest = true ; Ok ( ( ) ) }
If we're going to make a request of the backend, we should check that
its digest is what we expect.
If we ' re going to make a request of the backend we should check that its digest is what we expect .
&mut self
status
&mut dyn StatusBackend