MCPcopy Create free account
hub / github.com/archlinux/alpm / mtree

Method mtree

alpm-package/src/input.rs:554–574  ·  view source on GitHub ↗

Returns a reference to the [`Mtree`] data of the [`PackageInput`]. Compares the stored hash digest of the file with that of the file on disk. # Errors Returns an error if - the file on disk can no longer be read, - or the file on disk has a changed hash digest.

(&self)

Source from the content-addressed store, hash-verified

552 /// - the file on disk can no longer be read,
553 /// - or the file on disk has a changed hash digest.
554 pub fn mtree(&self) -> Result<&Mtree, crate::Error> {
555 let file_name = PathBuf::from(MetadataFileName::Mtree.as_ref());
556 let path = self.input_dir.join(file_name.as_path());
557 let buf = read(path.as_path()).map_err(|source| crate::Error::IoPath {
558 path: path.clone(),
559 context: t!("error-io-read-mtree"),
560 source,
561 })?;
562 let current_digest = Sha256Checksum::calculate_from(buf);
563 if current_digest != self.mtree_digest {
564 return Err(Error::FileHashDigestChanged {
565 path: file_name,
566 current_digest,
567 initial_digest: self.mtree_digest.clone(),
568 input_dir: self.input_dir.to_path_buf(),
569 }
570 .into());
571 }
572
573 Ok(&self.mtree)
574 }
575
576 /// Returns the optional [alpm-install-scriptlet] of the [`PackageInput`] as [`Path`] reference.
577 ///

Callers 2

try_fromMethod · 0.80

Calls 4

as_refMethod · 0.45
joinMethod · 0.45
as_pathMethod · 0.45
to_path_bufMethod · 0.45

Tested by 1