func (repo CloudControllerApplicationBitsRepository) extractZip(zipFile string, destDir string) (err error) { r, err := zip.OpenReader(zipFile) if err != nil { return } defer r.Close() for _, f := range r.File { func() { // Don't try to extract directories if f.FileInfo().IsDir() { return } if err != nil { return } var rc io.ReadCloser rc, err = f.Open() if err != nil { return } defer rc.Close() destFilePath := filepath.Join(destDir, f.Name) err = fileutils.CopyReaderToPath(rc, destFilePath) if err != nil { return } err = fileutils.SetExecutableBits(destFilePath, f.FileInfo()) if err != nil { return } }() } return }
func (repo CloudControllerApplicationBitsRepository) extractZip(appDir, destDir string) (err error) { r, err := zip.OpenReader(appDir) if err != nil { return } defer r.Close() for _, f := range r.File { func() { // Don't try to extract directories if f.FileInfo().IsDir() { return } var rc io.ReadCloser rc, err = f.Open() if err != nil { return } // functional scope from above is important // otherwise this only closes the last file handle defer rc.Close() destFilePath := filepath.Join(destDir, f.Name) err = fileutils.CopyReaderToPath(rc, destFilePath) if err != nil { return } err = fileutils.SetExecutableBits(destFilePath, f.FileInfo()) if err != nil { return } }() } return }