Ensure flusher is not nil

This commit is contained in:
Ignasi 2025-03-19 17:13:58 +01:00 committed by Jacob Howard
parent 0ea001602d
commit 9232cb2634
No known key found for this signature in database
GPG Key ID: 3E8B8F7FEB46FC66
1 changed files with 7 additions and 1 deletions

View File

@ -314,6 +314,10 @@ func (m *Manager) PullModel(ctx context.Context, model string, w http.ResponseWr
flusher: flusher,
}
if flusher == nil {
m.log.Warnln("HTTP response writer does not support flushing, progress updates may be delayed")
}
// Pull the model using the Docker model distribution client
m.log.Infoln("Pulling model:", model)
err := m.distributionClient.PullModel(ctx, model, progressWriter)
@ -337,6 +341,8 @@ func (w *progressResponseWriter) Write(p []byte) (n int, err error) {
return 0, err
}
// Flush the response to ensure the chunk is sent immediately
w.flusher.Flush()
if w.flusher != nil {
w.flusher.Flush()
}
return n, nil
}