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
1 changed files with 21 additions and 22 deletions

View File

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