提交 c83bbafb 作者: Kevin Atkinson

gc: stream all errors including the last

and report "encountered errors during gc run" as the response error

License: MIT
Signed-off-by: 's avatarKevin Atkinson <k@kevina.org>
上级 f338520a
......@@ -74,28 +74,26 @@ order to reclaim hard disk space.
go func() {
defer close(outChan)
unreportedError := false
var lastErr error
if streamErrors {
errs := false
for res := range gcOutChan {
if unreportedError {
outChan <- &GcResult{Error: lastErr.Error()}
unreportedError = false
}
if res.Error != nil {
lastErr = res.Error
unreportedError = true
outChan <- &GcResult{Error: res.Error.Error()}
errs = true
} else {
outChan <- &GcResult{Key: res.KeyRemoved}
}
}
if errs {
res.SetError(fmt.Errorf("encountered errors during gc run"), cmds.ErrNormal)
}
} else {
lastErr = corerepo.CollectResult(req.Context(), gcOutChan, func(k *cid.Cid) {
err := corerepo.CollectResult(req.Context(), gcOutChan, func(k *cid.Cid) {
outChan <- &GcResult{Key: k}
})
}
if lastErr != nil {
res.SetError(lastErr, cmds.ErrNormal)
if err != nil {
res.SetError(err, cmds.ErrNormal)
}
}
}()
},
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论