Skip to content

Commit

Permalink
fix(1906): increase compression speed using flate (#56)
Browse files Browse the repository at this point in the history
* fix(1906): increase compression speed using flate

* fix(1906): for pr build
  • Loading branch information
parthasl authored Jan 17, 2020
1 parent e492995 commit db97f79
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions sdstore/ziphelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sdstore

import (
"archive/zip"
"compress/flate"
"fmt"
"io"
"log"
Expand Down Expand Up @@ -43,15 +44,19 @@ var compressedFormats = map[string]struct{}{
// Zip is repurposed from https://github.com/mholt/archiver/pull/92/files
// To include support for symbolic links
func Zip(source, target string) error {
zipfile, err := os.Create(target)
zipFile, err := os.Create(target)
if err != nil {
return err
}
defer zipfile.Close()
defer zipFile.Close()

w := zip.NewWriter(zipfile)
w := zip.NewWriter(zipFile)
defer w.Close()

w.RegisterCompressor(zip.Deflate, func(out io.Writer) (io.WriteCloser, error) {
return flate.NewWriter(out, flate.BestSpeed)
})

sourceInfo, err := os.Stat(source)
if err != nil {
return fmt.Errorf("%s: stat: %v", source, err)
Expand Down

0 comments on commit db97f79

Please sign in to comment.