Skip to content

Commit

Permalink
fix defer writer, was causing corruption
Browse files Browse the repository at this point in the history
  • Loading branch information
tc80 committed Jul 7, 2020
1 parent d349a52 commit 0cf4923
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions compress/algorithm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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()
}

0 comments on commit 0cf4923

Please sign in to comment.