From e713f98daac180a0e4d9b5b88454827d13643f4b Mon Sep 17 00:00:00 2001 From: Arne Beer Date: Sat, 11 Jan 2025 20:23:23 +0100 Subject: [PATCH] fix: Task 0 being selected for restarted --- pueue/src/client/commands/restart.rs | 6 +++++- pueue_lib/src/network/message.rs | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pueue/src/client/commands/restart.rs b/pueue/src/client/commands/restart.rs index fab3bca4..72e4c54d 100644 --- a/pueue/src/client/commands/restart.rs +++ b/pueue/src/client/commands/restart.rs @@ -41,6 +41,10 @@ pub async fn restart( // Filter to get done tasks let done_filter = |task: &Task| task.is_done(); + // If all failed tasks or all failed tasks from a specific group are requested, + // determine the ids of those failed tasks. + // + // Otherwise, use the provided ids and check which of them were "Done" (successful or failed tasks). let filtered_tasks = if all_failed || failed_in_group.is_some() { // Either all failed tasks or all failed tasks of a specific group need to be restarted. @@ -91,7 +95,7 @@ pub async fn restart( let mut tasks: Vec = filtered_tasks .matching_ids .iter() - .map(|task_id| Task::from_task(state.tasks.get(task_id).unwrap())) + .map(|task_id| state.tasks.get(task_id).unwrap().clone()) .collect(); // If the tasks should be edited, edit them in one go. diff --git a/pueue_lib/src/network/message.rs b/pueue_lib/src/network/message.rs index 73146380..2df6d9d5 100644 --- a/pueue_lib/src/network/message.rs +++ b/pueue_lib/src/network/message.rs @@ -267,7 +267,6 @@ impl From<&Task> for EditableTask { impl EditableTask { /// Merge a [EditableTask] back into a [Task]. pub fn into_task(self, task: &mut Task) { - task.id = self.id; task.command = self.command; task.path = self.path; task.label = self.label;