From 0cf492343c0cd783bf9fad405b63bad793694f30 Mon Sep 17 00:00:00 2001 From: tylercaslin Date: Mon, 6 Jul 2020 17:59:52 -0400 Subject: [PATCH] fix defer writer, was causing corruption --- compress/algorithm.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compress/algorithm.go b/compress/algorithm.go index 1a75b1b5..70b9e188 100644 --- a/compress/algorithm.go +++ b/compress/algorithm.go @@ -14,9 +14,10 @@ func Brotli11(uncompressed []byte) []byte { var b bytes.Buffer w := brotli.NewWriterLevel(&b, brotli.BestCompression) + _, err := w.Write(uncompressed) util.Check(err) - util.Check(w.Flush()) + util.Check(w.Close()) return b.Bytes() } @@ -28,11 +29,10 @@ func Gzip9(uncompressed []byte) []byte { w, err := gzip.NewWriterLevel(&b, gzip.BestCompression) util.Check(err) - defer w.Close() _, err = w.Write(uncompressed) util.Check(err) - util.Check(w.Flush()) + util.Check(w.Close()) return b.Bytes() }