Fix handling of immediately started jobs

This commit is contained in:
WithoutPants 2026-03-16 17:43:51 +11:00
parent 56bfc43118
commit 50bef583ac

View file

@ -95,7 +95,18 @@ func (m *Manager) Start(ctx context.Context, description string, e JobExec) int
m.queue = append(m.queue, &j)
m.dispatch(ctx, &j)
m.notifyNewJob(&j)
done := m.dispatch(ctx, &j)
// handle removing the job from the queue when it is done
go func() {
<-done
m.mutex.Lock()
defer m.mutex.Unlock()
// remove the job from the queue
m.removeJob(&j)
}()
return j.ID
}