diff --git a/services/antivirus/pkg/service/service.go b/services/antivirus/pkg/service/service.go index eb9741e12..a23d8a54a 100644 --- a/services/antivirus/pkg/service/service.go +++ b/services/antivirus/pkg/service/service.go @@ -67,6 +67,7 @@ type Antivirus struct { // Run runs the service func (av Antivirus) Run() error { + ctx := context.Background() evtsCfg := av.c.Events var rootCAPool *x509.CertPool @@ -104,7 +105,7 @@ func (av Antivirus) Run() error { if av.c.DebugScanOutcome != "" { av.l.Warn().Str("antivir, clamav", ">>>>>>> ANTIVIRUS_DEBUG_SCAN_OUTCOME IS SET NO ACTUAL VIRUS SCAN IS PERFORMED!") - if err := events.Publish(context.Background(), stream, events.PostprocessingStepFinished{ + if err := events.Publish(ctx, stream, events.PostprocessingStepFinished{ FinishedStep: events.PPStepAntivirus, Outcome: events.PostprocessingOutcome(av.c.DebugScanOutcome), UploadID: ev.UploadID, @@ -142,7 +143,7 @@ func (av Antivirus) Run() error { } av.l.Info().Str("uploadid", ev.UploadID).Interface("resourceID", ev.ResourceID).Str("virus", res.Description).Str("outcome", string(outcome)).Str("filename", ev.Filename).Str("user", ev.ExecutingUser.GetId().GetOpaqueId()).Bool("infected", res.Infected).Msg("File scanned") - if err := events.Publish(context.Background(), stream, events.PostprocessingStepFinished{ + if err := events.Publish(ctx, stream, events.PostprocessingStepFinished{ FinishedStep: events.PPStepAntivirus, Outcome: outcome, UploadID: ev.UploadID, diff --git a/services/postprocessing/pkg/service/service.go b/services/postprocessing/pkg/service/service.go index ef9870f6f..2f261dfca 100644 --- a/services/postprocessing/pkg/service/service.go +++ b/services/postprocessing/pkg/service/service.go @@ -47,6 +47,7 @@ func NewPostprocessingService(stream events.Stream, logger log.Logger, sto store // Run to fulfil Runner interface func (pps *PostprocessingService) Run() error { + ctx := context.Background() for e := range pps.events { var ( next interface{} @@ -89,7 +90,7 @@ func (pps *PostprocessingService) Run() error { pp, err = getPP(pps.store, ev.UploadID) if err != nil { if err == store.ErrNotFound { - if err := events.Publish(context.Background(), pps.pub, events.RestartPostprocessing{ + if err := events.Publish(ctx, pps.pub, events.RestartPostprocessing{ UploadID: ev.UploadID, Timestamp: ev.Timestamp, }); err != nil { @@ -110,7 +111,7 @@ func (pps *PostprocessingService) Run() error { } } if next != nil { - if err := events.Publish(context.Background(), pps.pub, next); err != nil { + if err := events.Publish(ctx, pps.pub, next); err != nil { pps.log.Error().Err(err).Msg("unable to publish event") return err // we can't publish -> we are screwed }