mrutkows commented on a change in pull request #256: Add zipaction integration
test cases.
URL:
https://github.com/apache/incubator-openwhisk-wskdeploy/pull/256#discussion_r121971298
##########
File path: utils/misc.go
##########
@@ -156,96 +156,59 @@ func GetJSONType(j interface{}) string {
return kindToJSON[reflect.TypeOf(j).Kind()]
}
-// zip whole folder to a zip file
-func CreateFolderZip(src, des string) error {
- zippedFile, err := os.Create(des)
- Check(err)
- defer zippedFile.Close()
-
- zipWritter := zip.NewWriter(zippedFile)
- defer zipWritter.Close()
-
- sinfo, err := os.Stat(src)
- Check(err)
-
- var basedir string
- if sinfo.IsDir() {
- basedir = filepath.Base(src)
- }
-
- filepath.Walk(src, func(path string, finfo os.FileInfo, err error)
error {
- Check(err)
-
- header, err := zip.FileInfoHeader(finfo)
- Check(err)
-
- if basedir != "" {
- header.Name = filepath.Join(basedir,
strings.TrimPrefix(path, src))
- }
-
- if finfo.IsDir() {
- header.Name += "/"
- } else {
- header.Method = zip.Deflate
- }
-
- writer, err := zipWritter.CreateHeader(header)
- Check(err)
-
- file, err := os.Open(path)
- Check(err)
- defer file.Close()
- _, err = io.Copy(writer, file)
- Check(err)
- return err
- })
+func NewZipWritter(src, des string) *ZipWritter {
+ zw := &ZipWritter{src: src, des: des}
+ return zw
+}
- return err
+type ZipWritter struct {
Review comment:
name should be "ZipWriter"
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services