SnapshotReader: add self.datastore_name() helper

This commit is contained in:
Dietmar Maurer 2021-03-16 10:43:20 +01:00
parent 365126efa9
commit 0e2bf3aa1d

View File

@ -26,6 +26,7 @@ use crate::{
/// This make it easy to iterate over all used chunks and files. /// This make it easy to iterate over all used chunks and files.
pub struct SnapshotReader { pub struct SnapshotReader {
snapshot: BackupDir, snapshot: BackupDir,
datastore_name: String,
file_list: Vec<String>, file_list: Vec<String>,
locked_dir: Dir, locked_dir: Dir,
} }
@ -42,11 +43,13 @@ impl SnapshotReader {
"snapshot", "snapshot",
"locked by another operation")?; "locked by another operation")?;
let datastore_name = datastore.name().to_string();
let manifest = match datastore.load_manifest(&snapshot) { let manifest = match datastore.load_manifest(&snapshot) {
Ok((manifest, _)) => manifest, Ok((manifest, _)) => manifest,
Err(err) => { Err(err) => {
bail!("manifest load error on datastore '{}' snapshot '{}' - {}", bail!("manifest load error on datastore '{}' snapshot '{}' - {}",
datastore.name(), snapshot, err); datastore_name, snapshot, err);
} }
}; };
@ -60,7 +63,7 @@ impl SnapshotReader {
file_list.push(CLIENT_LOG_BLOB_NAME.to_string()); file_list.push(CLIENT_LOG_BLOB_NAME.to_string());
} }
Ok(Self { snapshot, file_list, locked_dir }) Ok(Self { snapshot, datastore_name, file_list, locked_dir })
} }
/// Return the snapshot directory /// Return the snapshot directory
@ -68,6 +71,11 @@ impl SnapshotReader {
&self.snapshot &self.snapshot
} }
/// Return the datastore name
pub fn datastore_name(&self) -> &str {
&self.datastore_name
}
/// Returns the list of files the snapshot refers to. /// Returns the list of files the snapshot refers to.
pub fn file_list(&self) -> &Vec<String> { pub fn file_list(&self) -> &Vec<String> {
&self.file_list &self.file_list