src/api2/admin/datastore.rs: use a worker log log prune actions
This commit is contained in:
parent
6899dbfb47
commit
dd8e744f9a
@ -171,7 +171,23 @@ fn prune(
|
||||
|
||||
let datastore = DataStore::lookup_datastore(store)?;
|
||||
|
||||
println!("Starting prune on store {}", store);
|
||||
let mut keep_all = true;
|
||||
|
||||
for opt in &["keep-last", "keep-daily", "keep-weekly", "keep-weekly", "keep-yearly"] {
|
||||
if !param[opt].is_null() {
|
||||
keep_all = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let worker = WorkerTask::new("prune", Some(store.to_owned()), "root@pam", true)?;
|
||||
let result = try_block! {
|
||||
if keep_all {
|
||||
worker.log("No selection - keeping all files.");
|
||||
return Ok(());
|
||||
} else {
|
||||
worker.log(format!("Starting prune on store {}", store));
|
||||
}
|
||||
|
||||
let backup_list = BackupInfo::list_backups(&datastore.base_path())?;
|
||||
|
||||
@ -219,10 +235,20 @@ fn prune(
|
||||
BackupInfo::sort_list(&mut remove_list, true);
|
||||
|
||||
for info in remove_list {
|
||||
worker.log(format!("remove {:?}", info.backup_dir));
|
||||
datastore.remove_backup_dir(&info.backup_dir)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
};
|
||||
|
||||
worker.log_result(&result);
|
||||
|
||||
if let Err(err) = result {
|
||||
bail!("prune failed - {}", err);
|
||||
}
|
||||
|
||||
Ok(json!(null))
|
||||
}
|
||||
|
||||
|
@ -106,8 +106,8 @@ fn upload_pxar(
|
||||
)
|
||||
.then(move |result| {
|
||||
match result {
|
||||
Ok((result,_)) => worker.log_result(Ok(result)),
|
||||
Err((err, _)) => worker.log_result(Err(err)),
|
||||
Ok((result,_)) => worker.log_result(&Ok(result)),
|
||||
Err((err, _)) => worker.log_result(&Err(err)),
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
|
@ -411,7 +411,7 @@ impl WorkerTask {
|
||||
let upid_str = worker.upid.to_string();
|
||||
|
||||
tokio::spawn(f(worker.clone()).then(move |result| {
|
||||
worker.log_result(result);
|
||||
worker.log_result(&result);
|
||||
Ok(())
|
||||
}));
|
||||
|
||||
@ -451,7 +451,7 @@ impl WorkerTask {
|
||||
}
|
||||
};
|
||||
|
||||
worker.log_result(result);
|
||||
worker.log_result(&result);
|
||||
p.send(()).unwrap();
|
||||
});
|
||||
|
||||
@ -461,7 +461,7 @@ impl WorkerTask {
|
||||
}
|
||||
|
||||
/// Log task result, remove task from running list
|
||||
pub fn log_result(&self, result: Result<(), Error>) {
|
||||
pub fn log_result(&self, result: &Result<(), Error>) {
|
||||
|
||||
if let Err(err) = result {
|
||||
self.log(&format!("TASK ERROR: {}", err));
|
||||
|
Loading…
Reference in New Issue
Block a user