Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions import-export-cli/impl/importAPIPolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ func importAPIPolicy(endpoint string, importPath string, accessToken string, isO
return err
}

policyPaths := strings.Split(tmpPath, "/")
policyName := policyPaths[len(policyPaths)-1]
// Make the file name platform independent
policyName := filepath.Base(tmpPath)

for _, file := range files {
originalFilePath := tmpPath + "/" + file.Name()
Expand Down
17 changes: 11 additions & 6 deletions import-export-cli/utils/fileIOUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,24 +413,29 @@ func CreateZipFileFromProject(projectPath string, skipCleanup bool) (string, err
if err != nil {
return "", err, nil
}
Logln(LogPrefixInfo+"Creating the project artifact", tmp.Name())
err = Zip(projectPath, tmp.Name())
// Read the filename and close the file to avoid file locking in windows
tmpPath := tmp.Name()
if err := tmp.Close(); err != nil {
return "", err, nil
}
Logln(LogPrefixInfo+"Creating the project artifact", tmpPath)
err = Zip(projectPath, tmpPath)
if err != nil {
return "", err, nil
}
//creates a function to cleanup the temporary folders
cleanup := func() {
if skipCleanup {
Logln(LogPrefixInfo+"Leaving", tmp.Name())
Logln(LogPrefixInfo+"Leaving", tmpPath)
return
}
Logln(LogPrefixInfo+"Deleting", tmp.Name())
err := os.Remove(tmp.Name())
Logln(LogPrefixInfo+"Deleting", tmpPath)
err := os.Remove(tmpPath)
if err != nil {
Logln(LogPrefixError + err.Error())
}
}
projectPath = tmp.Name()
projectPath = tmpPath
return projectPath, nil, cleanup
}
return projectPath, nil, nil
Expand Down
Loading