Backport #29354 by @KN4CK3R Fixes #29346 Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>tags/v1.21.7
// Close implements io.Closer | // Close implements io.Closer | ||||
func (b *blobReader) Close() error { | func (b *blobReader) Close() error { | ||||
if b.rd == nil { | |||||
return nil | |||||
} | |||||
defer b.cancel() | defer b.cancel() | ||||
return DiscardFull(b.rd, b.n+1) | |||||
if err := DiscardFull(b.rd, b.n+1); err != nil { | |||||
return err | |||||
} | |||||
b.rd = nil | |||||
return nil | |||||
} | } |
} | } | ||||
d, _ := io.ReadAll(dataRc) | d, _ := io.ReadAll(dataRc) | ||||
if err := dataRc.Close(); err != nil { | |||||
log.Error("Error whilst closing blob data: %v", err) | |||||
} | |||||
buf = append(buf, d...) | buf = append(buf, d...) | ||||
if content, err := charset.ToUTF8(buf, charset.ConvertOpts{KeepBOM: true}); err != nil { | if content, err := charset.ToUTF8(buf, charset.ConvertOpts{KeepBOM: true}); err != nil { |