Browse Source

bugfix for flush

贺伟 6 years ago
parent
commit
e303551daa
1 changed files with 5 additions and 1 deletions
  1. 5 1
      writer.go

+ 5 - 1
writer.go

@@ -213,7 +213,11 @@ func (z *Writer) Flush() error {
 		return nil
 	}
 
-	return z.compressBlock(z.data[:z.idx])
+	if err := z.compressBlock(z.data[:z.idx]); err != nil {
+		return err
+	}
+	z.idx = 0
+	return nil
 }
 
 // Close closes the Writer, flushing any unwritten data to the underlying io.Writer, but does not close the underlying io.Writer.