diff --git a/utils/utils.go b/utils/utils.go index 2e7572eb9..3376a15a1 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -11,6 +11,7 @@ import ( "os" "path/filepath" "strings" + "sync" "github.com/CycloneDX/cyclonedx-go" xscutils "github.com/jfrog/jfrog-client-go/xsc/services/utils" @@ -448,6 +449,7 @@ func isArtifactChecksumsMatch(remoteFileDetails *fileutils.FileDetails, localFil // LineDecoratorWriter is a line decorator that writes each line to the underlying writer with an optional prefix and suffix. type LineDecoratorWriter struct { + mu sync.Mutex w io.Writer prefix []byte suffix []byte @@ -465,6 +467,8 @@ func NewLineDecoratorWriter(w io.Writer, prefix, suffix string) *LineDecoratorWr } func (p *LineDecoratorWriter) Write(data []byte) (n int, err error) { + p.mu.Lock() + defer p.mu.Unlock() n = len(data) p.buf = append(p.buf, data...) for {