feat: add wrap for panic

This commit is contained in:
崔竞宁
2022-09-14 12:19:32 +08:00
parent a63d804054
commit 5e4e39988a
4 changed files with 47 additions and 17 deletions

View File

@@ -44,7 +44,7 @@ func (c *Copyer) startProgressBar(ctx context.Context) {
ch <- func() { logrus.StandardLogger().Logf(l, format, args...) }
}
go func() {
go wrap(ctx, func() {
copying := make(map[int64]struct{}, c.threads)
for f := range ch {
@@ -77,9 +77,9 @@ func (c *Copyer) startProgressBar(ctx context.Context) {
v()
}
}
}()
})
go func() {
go wrap(ctx, func() {
defer close(ch)
ticker := time.NewTicker(barUpdateInterval) // around 255ms, avoid conflict with progress bar fresh by second
@@ -112,5 +112,5 @@ func (c *Copyer) startProgressBar(ctx context.Context) {
return
}
}
}()
})
}