only create bzip file if needed. #415

This commit is contained in:
Oliver Sauder
2016-10-13 13:48:28 +02:00
parent 34ea7e8d61
commit fcd4429370
3 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -11,7 +11,7 @@ import (
//
// It uses internal gzip and external bzip2, see:
// https://code.google.com/p/go/issues/detail?id=4828
func CompressFile(source *os.File) error {
func CompressFile(source *os.File, onlyGzip bool) error {
gzPath := source.Name() + ".gz"
gzFile, err := os.Create(gzPath)
if err != nil {
@@ -24,7 +24,7 @@ func CompressFile(source *os.File) error {
source.Seek(0, 0)
_, err = io.Copy(gzWriter, source)
if err != nil {
if err != nil || onlyGzip {
return err
}
+1 -1
View File
@@ -27,7 +27,7 @@ func (s *CompressSuite) TearDownTest(c *C) {
}
func (s *CompressSuite) TestCompress(c *C) {
err := CompressFile(s.tempfile)
err := CompressFile(s.tempfile, false)
c.Assert(err, IsNil)
buf := make([]byte, len(testString))