feat: add bad dst check

This commit is contained in:
崔竞宁
2022-12-12 22:46:14 +08:00
parent ae151264e7
commit c5de5e5554
2 changed files with 8 additions and 1 deletions

View File

@@ -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")

View File

@@ -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) })
}