mirror of
https://github.com/mudler/LocalAI.git
synced 2026-01-04 09:40:32 -06:00
* feat(ui): allow to cancel ops Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * Improve progress text Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * Cancel queued ops, don't show up message cancellation always Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix: fixup displaying of total progress over multiple files Signed-off-by: Ettore Di Giacinto <mudler@localai.io> --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
22 lines
405 B
Go
22 lines
405 B
Go
package xio
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
)
|
|
|
|
type readerFunc func(p []byte) (n int, err error)
|
|
|
|
func (rf readerFunc) Read(p []byte) (n int, err error) { return rf(p) }
|
|
|
|
func Copy(ctx context.Context, dst io.Writer, src io.Reader) (int64, error) {
|
|
return io.Copy(dst, readerFunc(func(p []byte) (int, error) {
|
|
select {
|
|
case <-ctx.Done():
|
|
return 0, ctx.Err()
|
|
default:
|
|
return src.Read(p)
|
|
}
|
|
}))
|
|
}
|