tree-wide: prefer api-type BackupDir for logging

in combination with DatastoreWithNamespace to not lose the namespace
information.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler
2022-05-16 10:33:59 +02:00
committed by Thomas Lamprecht
parent f15601f1c9
commit 1afce610c7
6 changed files with 65 additions and 51 deletions

View File

@ -28,7 +28,8 @@ fn run() -> Result<(), Error> {
println!(" found group {}", group);
for snapshot in group.iter_snapshots()? {
println!("\t{}", snapshot?);
let snapshot = snapshot?;
println!("\t{}", snapshot.dir());
}
}
}

View File

@ -8,7 +8,7 @@ use nix::dir::Dir;
use proxmox_sys::fs::lock_dir_noblock_shared;
use pbs_api_types::{BackupNamespace, Operation};
use pbs_api_types::{BackupNamespace, DatastoreWithNamespace, Operation};
use crate::backup_info::BackupDir;
use crate::dynamic_index::DynamicIndexReader;
@ -39,20 +39,23 @@ impl SnapshotReader {
pub(crate) fn new_do(snapshot: BackupDir) -> Result<Self, Error> {
let datastore = snapshot.datastore();
let store_with_ns = DatastoreWithNamespace {
store: datastore.name().to_owned(),
ns: snapshot.backup_ns().clone(),
};
let snapshot_path = snapshot.full_path();
let locked_dir =
lock_dir_noblock_shared(&snapshot_path, "snapshot", "locked by another operation")?;
let datastore_name = datastore.name().to_string();
let manifest = match snapshot.load_manifest() {
Ok((manifest, _)) => manifest,
Err(err) => {
bail!(
"manifest load error on datastore '{}' snapshot '{}' - {}",
datastore_name,
snapshot,
"manifest load error on {}, snapshot '{}' - {}",
store_with_ns,
snapshot.dir(),
err
);
}