From 5584943c50c58216eaa47e9c59258e95e28fddf2 Mon Sep 17 00:00:00 2001 From: Samuel N Cui Date: Wed, 27 Sep 2023 18:07:27 +0800 Subject: [PATCH] feat: change shortcut --- copy.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/copy.go b/copy.go index 32517d6..e9bb9a8 100644 --- a/copy.go +++ b/copy.go @@ -73,11 +73,6 @@ func (c *Copyer) copy(ctx context.Context, prepared <-chan *writeJob) <-chan *ba return } - if noSpaceDevices.Contains(lo.Map(job.targets, func(target string, _ int) string { return c.getDevice(target) })...) { - job.fail("", ErrTargetNoSpace) - continue - } - wrap(ctx, func() { c.write(ctx, job, ch, cntr, noSpaceDevices) }) } } @@ -98,6 +93,12 @@ func (c *Copyer) write(ctx context.Context, job *writeJob, ch chan<- *baseJob, c ch <- job.baseJob }() + // shortcut + if noSpaceDevices.Contains(lo.Map(job.targets, func(target string, _ int) string { return c.getDevice(target) })...) { + job.fail("", ErrTargetNoSpace) + return + } + atomic.AddInt64(&cntr.files, 1) chans := make([]chan []byte, 0, len(job.targets)+1) defer func() {