Skip to content

Commit

Permalink
Fix for Stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
phutelmyer committed Dec 27, 2022
1 parent 10a3c96 commit 20c8aa0
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/go/pkg/rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"io"
"log"
"os"
"path/filepath"
"runtime"
"time"
"path/filepath"

"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
Expand Down Expand Up @@ -111,14 +111,13 @@ func PrintResponses(responses <-chan *strelka.ScanResponse) {
nl := osNewline()
for r := range responses {
if r != nil {
os.stdout.WriteString(fmt.Sprintf("%s%s", r.Event, nl))
os.Stdout.WriteString(fmt.Sprintf("%s%s", r.Event, nl))
continue
}
break
}
}


// Discards responses
func DiscardResponses(responses <-chan *strelka.ScanResponse) {
for r := range responses {
Expand All @@ -142,15 +141,15 @@ func ScanFile(client strelka.FrontendClient, timeout time.Duration, req structs.
if req.Delete {
defer os.Remove(req.Attributes.Filename)
} else if req.Processed != "" {
defer func() {
_, name := filepath.Split(req.Attributes.Filename)
m := filepath.Join(req.Processed, name)
err := os.Rename(req.Attributes.Filename, m)
if err != nil {
log.Printf("failed to move file %s to directory %s: %v", name, req.Processed, err)
}
}()
}
defer func() {
_, name := filepath.Split(req.Attributes.Filename)
m := filepath.Join(req.Processed, name)
err := os.Rename(req.Attributes.Filename, m)
if err != nil {
log.Printf("failed to move file %s to directory %s: %v", name, req.Processed, err)
}
}()
}
defer file.Close()

scanFile, err := client.ScanFile(ctx, grpc.WaitForReady(true))
Expand Down

0 comments on commit 20c8aa0

Please sign in to comment.