Another fix for the written byte counting, this time for parts (alt/attach/embed)

This commit is contained in:
Winni Neessen 2022-03-19 18:32:51 +01:00
parent 429c9a1883
commit 68049b568d
Signed by: wneessen
GPG key ID: 5F3AF39B820C119D

View file

@ -260,8 +260,11 @@ func (mw *msgWriter) writeBody(f func(io.Writer) (int64, error), e Encoding) {
case EncodingB64: case EncodingB64:
ew = base64.NewEncoder(base64.StdEncoding, &wbuf) ew = base64.NewEncoder(base64.StdEncoding, &wbuf)
case NoEncoding: case NoEncoding:
n, mw.err = f(w) _, mw.err = f(&wbuf)
mw.n += n n, mw.err = io.Copy(w, &wbuf)
if mw.d == 0 {
mw.n += n
}
return return
default: default:
ew = quotedprintable.NewWriter(w) ew = quotedprintable.NewWriter(w)
@ -270,5 +273,10 @@ func (mw *msgWriter) writeBody(f func(io.Writer) (int64, error), e Encoding) {
_, mw.err = f(ew) _, mw.err = f(ew)
mw.err = ew.Close() mw.err = ew.Close()
n, mw.err = io.Copy(w, &wbuf) n, mw.err = io.Copy(w, &wbuf)
mw.n += n
// Since the part writer uses the Write() method, we don't need to add the
// bytes twice
if mw.d == 0 {
mw.n += n
}
} }