@@ -10,32 +10,37 @@ pub(crate) fn prune_journal(
1010 live_worker_ids : & Set < WorkerId > ,
1111) -> crate :: Result < ( ) > {
1212 for event in reader {
13- let event = event?;
14- let retain = match & event. payload {
13+ let mut event = event?;
14+ let event = match & mut event. payload {
1515 EventPayload :: WorkerConnected ( worker_id, _)
16- | EventPayload :: WorkerLost ( worker_id, _) => live_worker_ids. contains ( worker_id) ,
16+ | EventPayload :: WorkerLost ( worker_id, _) => {
17+ live_worker_ids. contains ( worker_id) . then_some ( event)
18+ }
1719 EventPayload :: WorkerOverviewReceived ( overview) => {
18- live_worker_ids. contains ( & overview. id )
20+ live_worker_ids. contains ( & overview. id ) . then_some ( event )
1921 }
2022 EventPayload :: Submit { job_id, .. }
2123 | EventPayload :: JobCompleted ( job_id)
2224 | EventPayload :: JobOpen ( job_id, _)
23- | EventPayload :: JobClose ( job_id) => live_job_ids. contains ( job_id) ,
25+ | EventPayload :: JobClose ( job_id) => live_job_ids. contains ( job_id) . then_some ( event ) ,
2426 EventPayload :: TaskStarted { task_id, .. }
2527 | EventPayload :: TaskFinished { task_id, .. }
26- | EventPayload :: TaskFailed { task_id, .. }
27- | EventPayload :: TaskCanceled { task_id, .. } => {
28- live_job_ids. contains ( & task_id. job_id ( ) )
28+ | EventPayload :: TaskFailed { task_id, .. } => {
29+ live_job_ids. contains ( & task_id. job_id ( ) ) . then_some ( event)
30+ }
31+ EventPayload :: TaskCanceled { task_ids, .. } => {
32+ task_ids. retain ( |id| live_job_ids. contains ( & id. job_id ( ) ) ) ;
33+ ( !task_ids. is_empty ( ) ) . then_some ( event)
2934 }
3035 EventPayload :: AllocationQueueCreated ( _, _)
3136 | EventPayload :: AllocationQueueRemoved ( _)
3237 | EventPayload :: AllocationQueued { .. }
3338 | EventPayload :: AllocationStarted ( _, _)
3439 | EventPayload :: AllocationFinished ( _, _)
3540 | EventPayload :: ServerStart { .. }
36- | EventPayload :: ServerStop => true ,
41+ | EventPayload :: ServerStop => Some ( event ) ,
3742 } ;
38- if retain {
43+ if let Some ( event ) = event {
3944 writer. store ( event) ?;
4045 }
4146 }
0 commit comments