Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
use fixed path sep char
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Feb 17, 2022
1 parent a09a5bc commit 94d2703
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions bundlegen/proxybundle/proxybundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ func archiveBundle(pathToZip, destinationPath string) (err error) {

var destinationFile *os.File

pathSep := `/` //For archives/zip the path separator is always /

destinationFile, err = os.Create(destinationPath)
if err != nil {
return err
Expand All @@ -308,18 +310,16 @@ func archiveBundle(pathToZip, destinationPath string) (err error) {
myZip := zip.NewWriter(destinationFile)
err = filepath.Walk(pathToZip, func(filePath string, info os.FileInfo, err error) error {
if info.IsDir() {
relPath := strings.TrimPrefix(filePath, filepath.Dir(pathToZip))
zipEntry := strings.ReplaceAll(strings.TrimPrefix(relPath, string(os.PathSeparator))+string(os.PathSeparator), string(os.PathSeparator)+string(os.PathSeparator), string(os.PathSeparator))
clilog.Info.Println(zipEntry)
relPath := filepath.ToSlash(strings.TrimPrefix(filePath, filepath.Dir(pathToZip)))
zipEntry := strings.TrimPrefix(relPath, pathSep) + pathSep
_, err = myZip.Create(zipEntry)
return err
}
if err != nil {
return err
}
relPath := strings.TrimPrefix(filePath, filepath.Dir(pathToZip))
zipEntry := strings.ReplaceAll(strings.TrimPrefix(relPath, string(os.PathSeparator)), string(os.PathSeparator)+string(os.PathSeparator), string(os.PathSeparator))
clilog.Info.Println(zipEntry)
relPath := filepath.ToSlash(strings.TrimPrefix(filePath, filepath.Dir(pathToZip)))
zipEntry := strings.TrimPrefix(relPath, pathSep)
zipFile, err := myZip.Create(zipEntry)
if err != nil {
return err
Expand Down

0 comments on commit 94d2703

Please sign in to comment.