Commit 7d33d39d authored by Ross Smith II's avatar Ross Smith II

Skip gzip compression if compression_level=0

parent 66a256fd
......@@ -11,6 +11,7 @@ FEATURES:
IMPROVEMENTS:
* Vagrant post-processor skips gzip compression when compression_level=0
* builder/amazon/all: Can now specify a list of multiple security group
IDs to apply. [GH-499]
* builder/amazon/all: AWS API requests are now retried when a temporary
......
......@@ -2,6 +2,7 @@ package vagrant
import (
"archive/tar"
"compress/flate"
"compress/gzip"
"encoding/json"
"fmt"
......@@ -52,13 +53,22 @@ func DirToBox(dst, dir string, ui packer.Ui, level int) error {
}
defer dstF.Close()
gzipWriter, err := gzip.NewWriterLevel(dstF, level)
if err != nil {
return err
var tarOrGzipWriter io.Writer
if level != flate.NoCompression {
log.Printf("Compressing with gzip compression level %v", level)
gzipWriter, err := gzip.NewWriterLevel(dstF, level)
if err != nil {
return err
}
defer gzipWriter.Close()
tarOrGzipWriter = gzipWriter
} else {
log.Printf("Skipping gzip compression")
tarOrGzipWriter = dstF
}
defer gzipWriter.Close()
tarWriter := tar.NewWriter(gzipWriter)
tarWriter := tar.NewWriter(tarOrGzipWriter)
defer tarWriter.Close()
// This is the walk func that tars each of the files in the dir
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment