From 57a1c9bea27f5d542444c409a768b331fc5e0cb9 Mon Sep 17 00:00:00 2001 From: pancho horrillo Date: Sat, 1 Oct 2016 23:20:58 +0200 Subject: [PATCH] pixiecore: return file size on apibooter version of ReadBootFile (#14) Otherwise Content-Length header cannot be properly set, and this causes issues with iPXE. --- pixiecore/booters.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pixiecore/booters.go b/pixiecore/booters.go index 42bc16c..f29bee0 100644 --- a/pixiecore/booters.go +++ b/pixiecore/booters.go @@ -254,7 +254,16 @@ func (b *apibooter) ReadBootFile(id ID) (io.ReadCloser, int64, error) { ) if u.Scheme == "file" { // TODO serveFile - ret, err = os.Open(u.Path) + f, err := os.Open(u.Path) + if err != nil { + return nil, -1, err + } + fi, err := f.Stat() + if err != nil { + f.Close() + return nil, -1, err + } + ret, sz = f, fi.Size() } else { // urlStr will get reparsed by http.Get, which is mildly // wasteful, but the code looks nicer than constructing a