fix flushing of transparently compressed gzip output

this is a problem for connections like SSE, that only send data on events.
those events would stay in the gzip buffer until lots more data was written.

bug because of automatically typing "if err != nil"...

found while testing the maildir/mbox web-based import while working on message
threading support. the import gets progress SSE events that were now hanging.
This commit is contained in:
Mechiel Lukkien 2023-09-12 21:22:08 +02:00
parent 6f1e38f2ce
commit b754b5f9ac
No known key found for this signature in database

View file

@ -140,7 +140,7 @@ func (w *loggingWriter) Write(buf []byte) (int, error) {
// issues due to buffering. // issues due to buffering.
// w.Gzip.Write updates w.Size with the compressed byte count. // w.Gzip.Write updates w.Size with the compressed byte count.
n, err = w.Gzip.Write(buf) n, err = w.Gzip.Write(buf)
if err != nil { if err == nil {
err = w.Gzip.Flush() err = w.Gzip.Flush()
} }
if n > 0 { if n > 0 {