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)
| 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 | /// |