mirror of
https://github.com/samuelncui/acp.git
synced 2025-12-23 05:05:15 +00:00
fix: linear
This commit is contained in:
23
job.go
23
job.go
@@ -126,9 +126,30 @@ type writeJob struct {
|
||||
ch chan struct{}
|
||||
}
|
||||
|
||||
func newWriteJob(job *baseJob, src *mmap.ReaderAt, needWait bool) *writeJob {
|
||||
j := &writeJob{
|
||||
baseJob: job,
|
||||
src: src,
|
||||
}
|
||||
if needWait {
|
||||
j.ch = make(chan struct{})
|
||||
}
|
||||
return j
|
||||
}
|
||||
|
||||
func (wj *writeJob) done() {
|
||||
wj.src.Close()
|
||||
close(wj.ch)
|
||||
|
||||
if wj.ch != nil {
|
||||
close(wj.ch)
|
||||
}
|
||||
}
|
||||
|
||||
func (wj *writeJob) wait() {
|
||||
if wj.ch == nil {
|
||||
return
|
||||
}
|
||||
<-wj.ch
|
||||
}
|
||||
|
||||
type Job struct {
|
||||
|
||||
4
opt.go
4
opt.go
@@ -91,6 +91,10 @@ func (o *option) check() error {
|
||||
|
||||
o.fromDevice.check()
|
||||
o.toDevice.check()
|
||||
if o.fromDevice.linear || o.toDevice.linear {
|
||||
o.fromDevice.threads = 1
|
||||
o.toDevice.threads = 1
|
||||
}
|
||||
if o.logger == nil {
|
||||
o.logger = logrus.StandardLogger()
|
||||
}
|
||||
|
||||
@@ -45,9 +45,9 @@ func (c *Copyer) prepare(ctx context.Context, indexed <-chan *baseJob) <-chan *w
|
||||
return
|
||||
}
|
||||
|
||||
wj := &writeJob{baseJob: job, src: file, ch: make(chan struct{})}
|
||||
wj := newWriteJob(job, file, c.fromDevice.linear)
|
||||
ch <- wj
|
||||
<-wj.ch
|
||||
wj.wait()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user