server/worker_task: factor out task list rendering
we will need this later again Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
005a5b9677
commit
bbeb0256f1
@ -413,15 +413,7 @@ fn update_active_workers(new_upid: Option<&UPID>) -> Result<Vec<TaskListInfo>, E
|
||||
}
|
||||
});
|
||||
|
||||
let mut raw = String::new();
|
||||
for info in &task_list {
|
||||
if let Some(status) = &info.state {
|
||||
raw.push_str(&format!("{} {:08X} {}\n", info.upid_str, status.endtime(), status));
|
||||
} else {
|
||||
raw.push_str(&info.upid_str);
|
||||
raw.push('\n');
|
||||
}
|
||||
}
|
||||
let raw = render_task_list(&task_list[..]);
|
||||
|
||||
replace_file(
|
||||
PROXMOX_BACKUP_ACTIVE_TASK_FN,
|
||||
@ -443,6 +435,26 @@ pub fn read_task_list() -> Result<Vec<TaskListInfo>, Error> {
|
||||
update_active_workers(None)
|
||||
}
|
||||
|
||||
fn render_task_line(info: &TaskListInfo) -> String {
|
||||
let mut raw = String::new();
|
||||
if let Some(status) = &info.state {
|
||||
raw.push_str(&format!("{} {:08X} {}\n", info.upid_str, status.endtime(), status));
|
||||
} else {
|
||||
raw.push_str(&info.upid_str);
|
||||
raw.push('\n');
|
||||
}
|
||||
|
||||
raw
|
||||
}
|
||||
|
||||
fn render_task_list(list: &[TaskListInfo]) -> String {
|
||||
let mut raw = String::new();
|
||||
for info in list {
|
||||
raw.push_str(&render_task_line(&info));
|
||||
}
|
||||
raw
|
||||
}
|
||||
|
||||
/// Launch long running worker tasks.
|
||||
///
|
||||
/// A worker task can either be a whole thread, or a simply tokio
|
||||
|
Loading…
Reference in New Issue
Block a user