1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-11-06 09:09:29 +02:00

fix: mutex on checksum refresh

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
This commit is contained in:
Carlos A Becker
2021-12-22 14:42:18 -03:00
parent 8e3fa2cb36
commit 114c980726

View File

@@ -9,6 +9,7 @@ import (
"path/filepath" "path/filepath"
"sort" "sort"
"strings" "strings"
"sync"
"github.com/apex/log" "github.com/apex/log"
"github.com/goreleaser/goreleaser/internal/artifact" "github.com/goreleaser/goreleaser/internal/artifact"
@@ -18,7 +19,10 @@ import (
"github.com/goreleaser/goreleaser/pkg/context" "github.com/goreleaser/goreleaser/pkg/context"
) )
var errNoArtifacts = errors.New("there are no artifacts to sign") var (
errNoArtifacts = errors.New("there are no artifacts to sign")
lock sync.Mutex
)
// Pipe for checksums. // Pipe for checksums.
type Pipe struct{} type Pipe struct{}
@@ -65,6 +69,8 @@ func (Pipe) Run(ctx *context.Context) error {
} }
func refresh(ctx *context.Context, filepath string) error { func refresh(ctx *context.Context, filepath string) error {
lock.Lock()
defer lock.Unlock()
filter := artifact.Or( filter := artifact.Or(
artifact.ByType(artifact.UploadableArchive), artifact.ByType(artifact.UploadableArchive),
artifact.ByType(artifact.UploadableBinary), artifact.ByType(artifact.UploadableBinary),
@@ -132,7 +138,7 @@ func refresh(ctx *context.Context, filepath string) error {
} }
func checksums(algorithm string, artifact *artifact.Artifact) (string, error) { func checksums(algorithm string, artifact *artifact.Artifact) (string, error) {
log.WithField("file", artifact.Name).Info("checksumming") log.WithField("file", artifact.Name).Debug("checksumming")
sha, err := artifact.Checksum(algorithm) sha, err := artifact.Checksum(algorithm)
if err != nil { if err != nil {
return "", err return "", err