Skip to content

Commit c412b7d

Browse files
authored
Merge pull request #1356 from DDH13/4.6.x.16462
[APIM 4.6.0] Fix file path issue
2 parents e3527f4 + 9866c8a commit c412b7d

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

‎import-export-cli/impl/importAPIPolicy.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ func importAPIPolicy(endpoint string, importPath string, accessToken string, isO
7676
return err
7777
}
7878

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

8282
for _, file := range files {
8383
originalFilePath := tmpPath + "/" + file.Name()

‎import-export-cli/utils/fileIOUtils.go‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -413,24 +413,29 @@ func CreateZipFileFromProject(projectPath string, skipCleanup bool) (string, err
413413
if err != nil {
414414
return "", err, nil
415415
}
416-
Logln(LogPrefixInfo+"Creating the project artifact", tmp.Name())
417-
err = Zip(projectPath, tmp.Name())
416+
// Read the filename and close the file to avoid file locking in windows
417+
tmpPath := tmp.Name()
418+
if err := tmp.Close(); err != nil {
419+
return "", err, nil
420+
}
421+
Logln(LogPrefixInfo+"Creating the project artifact", tmpPath)
422+
err = Zip(projectPath, tmpPath)
418423
if err != nil {
419424
return "", err, nil
420425
}
421426
//creates a function to cleanup the temporary folders
422427
cleanup := func() {
423428
if skipCleanup {
424-
Logln(LogPrefixInfo+"Leaving", tmp.Name())
429+
Logln(LogPrefixInfo+"Leaving", tmpPath)
425430
return
426431
}
427-
Logln(LogPrefixInfo+"Deleting", tmp.Name())
428-
err := os.Remove(tmp.Name())
432+
Logln(LogPrefixInfo+"Deleting", tmpPath)
433+
err := os.Remove(tmpPath)
429434
if err != nil {
430435
Logln(LogPrefixError + err.Error())
431436
}
432437
}
433-
projectPath = tmp.Name()
438+
projectPath = tmpPath
434439
return projectPath, nil, cleanup
435440
}
436441
return projectPath, nil, nil

0 commit comments

Comments
 (0)