Base64 encoder closing (#822)

Signed-off-by: houdini91 <mdstrauss91@gmail.com>
This commit is contained in:
mikey strauss 2022-02-17 20:10:08 +02:00 committed by GitHub
parent 641c44f449
commit e6b5872bc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,9 +64,11 @@ func (i *ContentsCataloger) catalogLocation(resolver source.FileResolver, locati
defer internal.CloseAndLogError(contentReader, location.VirtualPath) defer internal.CloseAndLogError(contentReader, location.VirtualPath)
buf := &bytes.Buffer{} buf := &bytes.Buffer{}
if _, err = io.Copy(base64.NewEncoder(base64.StdEncoding, buf), contentReader); err != nil { encoder := base64.NewEncoder(base64.StdEncoding, buf)
if _, err = io.Copy(encoder, contentReader); err != nil {
return "", internal.ErrPath{Path: location.RealPath, Err: err} return "", internal.ErrPath{Path: location.RealPath, Err: err}
} }
encoder.Close()
return buf.String(), nil return buf.String(), nil
} }