From 5f9cb755a89beb21c0bc6f416178b395c5889a97 Mon Sep 17 00:00:00 2001 From: Mukundan Sundararajan Date: Mon, 13 Jul 2020 20:18:57 -0700 Subject: [PATCH] Fix/windows cli issue (#394) * Close ZipReader properly * Do not remove bin file on extraction --- pkg/standalone/common.go | 2 +- pkg/standalone/standalone.go | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/pkg/standalone/common.go b/pkg/standalone/common.go index 535ad2cab..5925c06af 100644 --- a/pkg/standalone/common.go +++ b/pkg/standalone/common.go @@ -43,7 +43,7 @@ func binaryFilePath(binaryFilePrefix, installLocation string) string { destDir := binaryInstallationPath(installLocation) binaryPath := path_filepath.Join(destDir, binaryFilePrefix) if runtime.GOOS == daprWindowsOS { - binaryPath = path_filepath.Join(binaryPath, ".exe") + binaryPath += ".exe" } return binaryPath } diff --git a/pkg/standalone/standalone.go b/pkg/standalone/standalone.go index 66257ddf5..b3db74733 100644 --- a/pkg/standalone/standalone.go +++ b/pkg/standalone/standalone.go @@ -520,13 +520,6 @@ func installBinary(wg *sync.WaitGroup, errorChan chan<- error, dir, version, bin return } - err = os.Remove(extractedFilePath) - - if err != nil { - errorChan <- fmt.Errorf("failed to remove extracted binary: %s", err) - return - } - err = makeExecutable(binaryPath) if err != nil { errorChan <- fmt.Errorf("error making %s binary executable: %s", binaryFilePrefix, err) @@ -597,6 +590,7 @@ func unzip(filepath, targetDir string) (string, error) { if err != nil { return "", err } + defer zipReader.Close() if len(zipReader.Reader.File) > 0 { file := zipReader.Reader.File[0]