From c5de5e5554288c550ff80e29db433cfac00e4129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=94=E7=AB=9E=E5=AE=81?= Date: Mon, 12 Dec 2022 22:46:14 +0800 Subject: [PATCH] feat: add bad dst check --- cmd/acp/main.go | 4 ++++ copy.go | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/acp/main.go b/cmd/acp/main.go index 251a5a1..d41430a 100644 --- a/cmd/acp/main.go +++ b/cmd/acp/main.go @@ -7,6 +7,7 @@ import ( "os/signal" "github.com/abc950309/acp" + "github.com/klauspost/cpuid/v2" "github.com/sirupsen/logrus" ) @@ -33,7 +34,10 @@ func init() { func main() { ctx, cancel := context.WithCancel(context.Background()) + cpuid.Flags() flag.Parse() + cpuid.Detect() + sources := flag.Args() if len(sources) == 0 { logrus.Fatalf("cannot found source path") diff --git a/copy.go b/copy.go index cd1d5f5..4f911b2 100644 --- a/copy.go +++ b/copy.go @@ -15,7 +15,7 @@ import ( "github.com/abc950309/acp/mmap" mapset "github.com/deckarep/golang-set/v2" "github.com/hashicorp/go-multierror" - "github.com/minio/sha256-simd" + sha256 "github.com/minio/sha256-simd" ) const ( @@ -68,6 +68,9 @@ func (c *Copyer) copy(ctx context.Context, prepared <-chan *writeJob) <-chan *ba if !ok { return } + if badDsts.Cardinality() >= len(c.dst) { + return + } wrap(ctx, func() { c.write(ctx, job, ch, cntr, badDsts) }) }