diff --git a/internal/file/service.go b/internal/file/service.go index 76ea002..cf057bc 100644 --- a/internal/file/service.go +++ b/internal/file/service.go @@ -220,10 +220,26 @@ func (s service) Create(ctx context.Context, req CreateFileRequest) ( time.Sleep(10 * time.Second) } + // Check if the upload failed. if err != nil { s.logger.Error(err) return } + + // Serialize the msg to send to the orchestrator. + msg, err := json.Marshal(FileScanCfg{SHA256: sha256, FileScanRequest: req.scanCfg}) + if err != nil { + s.logger.Error(err) + return + } + + // Push a message to the queue to scan this file. + err = s.producer.Produce(s.topic, msg) + if err != nil { + s.logger.Error(err) + return + } + }() // Get the source of the HTTP request from the ctx. @@ -272,20 +288,6 @@ func (s service) Create(ctx context.Context, req CreateFileRequest) ( return File{}, err } - // Serialize the msg to send to the orchestrator. - msg, err := json.Marshal(FileScanCfg{SHA256: sha256, FileScanRequest: req.scanCfg}) - if err != nil { - s.logger.With(ctx).Error(err) - return File{}, err - } - - // Push a message to the queue to scan this file. - err = s.producer.Produce(s.topic, msg) - if err != nil { - s.logger.With(ctx).Error(err) - return File{}, err - } - return s.Get(ctx, sha256, nil) } else {