fix: panic while create empty file

This commit is contained in:
Noah Hsu 2022-09-03 19:32:44 +08:00
parent 552aba997c
commit dcc99802ec

View File

@ -31,7 +31,7 @@ func CopyWithCtx(ctx context.Context, out io.Writer, in io.Reader, size int64, p
default: default:
// otherwise just run default io.Reader implementation // otherwise just run default io.Reader implementation
n, err := in.Read(p) n, err := in.Read(p)
if err == nil || err == io.EOF { if s > 0 && (err == nil || err == io.EOF) {
finish += int64(n) finish += int64(n)
progress(int(finish / s)) progress(int(finish / s))
} }