diff --git a/main.go b/main.go index 94d1704..7ded826 100644 --- a/main.go +++ b/main.go @@ -106,11 +106,17 @@ func scanHandler(w http.ResponseWriter, r *http.Request) { wg.Done() } + log.WithField("contentType", contentType).Debug("Adding files from multipart form as jobs") + + fileCount := 0 + for _, files := range r.MultipartForm.File { // Append files for _, file := range files { wg.Add(1) + fileCount++ + f, err := file.Open() if err != nil { @@ -126,6 +132,8 @@ func scanHandler(w http.ResponseWriter, r *http.Request) { } } + log.WithField("count", fileCount).Debug("Waiting for jobs to finish") + wg.Wait() json.NewEncoder(w).Encode(results) @@ -137,6 +145,8 @@ func scanHandler(w http.ResponseWriter, r *http.Request) { }, } + log.WithField("contentType", contentType).Debug("Scanning contents of body") + jobChan <- job } } @@ -204,6 +214,8 @@ func worker(rules *yara.Rules) { for { job := <-jobChan + log.Debug("Processing job") + processJob(s, job) } }