mirror of
https://github.com/ggml-org/whisper.cpp.git
synced 2026-10-22 03:48:19 +02:00
go : handle EOF correctly in model download (#3671)
This commit is contained in:
@@ -282,13 +282,20 @@ func Download(ctx context.Context, p io.Writer, model, out string) (string, erro
|
|||||||
default:
|
default:
|
||||||
// Read body
|
// Read body
|
||||||
n, err := resp.Body.Read(data)
|
n, err := resp.Body.Read(data)
|
||||||
|
if n > 0 {
|
||||||
|
if m, err := w.Write(data[:n]); err != nil {
|
||||||
|
return path, err
|
||||||
|
} else {
|
||||||
|
count += int64(m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
DownloadReport(p, pct, count, resp.ContentLength)
|
if err == io.EOF {
|
||||||
|
DownloadReport(p, pct, count, resp.ContentLength)
|
||||||
|
return path, nil
|
||||||
|
}
|
||||||
return path, err
|
return path, err
|
||||||
} else if m, err := w.Write(data[:n]); err != nil {
|
|
||||||
return path, err
|
|
||||||
} else {
|
|
||||||
count += int64(m)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user