pull: use API BackupDir for log messages

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2022-05-16 09:30:20 +02:00
parent 6bfc94ea19
commit e3ea577011

View File

@ -384,6 +384,8 @@ async fn pull_snapshot(
let mut tmp_manifest_name = manifest_name.clone();
tmp_manifest_name.set_extension("tmp");
let dir: &pbs_api_types::BackupDir = snapshot.as_ref();
let download_res = download_manifest(&reader, &tmp_manifest_name).await;
let mut tmp_manifest_file = match download_res {
Ok(manifest_file) => manifest_file,
@ -393,7 +395,7 @@ async fn pull_snapshot(
StatusCode::NOT_FOUND => {
task_log!(
worker,
"skipping snapshot {snapshot} - vanished since start of sync",
"skipping snapshot {dir} - vanished since start of sync",
);
return Ok(());
}
@ -516,29 +518,30 @@ async fn pull_snapshot_from(
snapshot: &pbs_datastore::BackupDir,
downloaded_chunks: Arc<Mutex<HashSet<[u8; 32]>>>,
) -> Result<(), Error> {
let dir: &pbs_api_types::BackupDir = snapshot.as_ref();
let (_path, is_new, _snap_lock) = snapshot
.datastore()
.create_locked_backup_dir(snapshot.backup_ns(), snapshot.as_ref())?;
.create_locked_backup_dir(snapshot.backup_ns(), dir)?;
let snapshot_path = snapshot.to_string();
if is_new {
task_log!(worker, "sync snapshot {:?}", snapshot_path);
task_log!(worker, "sync snapshot {}", dir);
if let Err(err) = pull_snapshot(worker, reader, snapshot, downloaded_chunks).await {
if let Err(cleanup_err) = snapshot.datastore().remove_backup_dir(
snapshot.backup_ns(),
snapshot.as_ref(),
true,
) {
if let Err(cleanup_err) =
snapshot
.datastore()
.remove_backup_dir(snapshot.backup_ns(), dir, true)
{
task_log!(worker, "cleanup error - {}", cleanup_err);
}
return Err(err);
}
task_log!(worker, "sync snapshot {:?} done", snapshot_path);
task_log!(worker, "sync snapshot {} done", dir);
} else {
task_log!(worker, "re-sync snapshot {:?}", snapshot_path);
task_log!(worker, "re-sync snapshot {}", dir);
pull_snapshot(worker, reader, snapshot, downloaded_chunks).await?;
task_log!(worker, "re-sync snapshot {:?} done", snapshot_path);
task_log!(worker, "re-sync snapshot {} done", dir);
}
Ok(())
@ -713,26 +716,22 @@ async fn pull_group(
let group = params.store.backup_group(target_ns.clone(), group.clone());
let local_list = group.list_backups()?;
for info in local_list {
let backup_time = info.backup_dir.backup_time();
if remote_snapshots.contains(&backup_time) {
let snapshot: &pbs_api_types::BackupDir = info.backup_dir.as_ref();
if remote_snapshots.contains(&snapshot.time) {
continue;
}
if info.backup_dir.is_protected() {
task_log!(
worker,
"don't delete vanished snapshot {:?} (protected)",
info.backup_dir.relative_path()
"don't delete vanished snapshot {} (protected)",
snapshot
);
continue;
}
task_log!(
worker,
"delete vanished snapshot {:?}",
info.backup_dir.relative_path()
);
task_log!(worker, "delete vanished snapshot {}", snapshot);
params
.store
.remove_backup_dir(&target_ns, info.backup_dir.as_ref(), false)?;
.remove_backup_dir(&target_ns, snapshot, false)?;
}
}