Skip to content

Commit

Permalink
fix location of solution download zip file (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
pnickolov committed May 4, 2024
1 parent adf5aec commit aa33378
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/solution/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ func downloadSolution(cmd *cobra.Command, args []string) {
solutionName := getSolutionNameFromArgs(cmd, args, "name")
solutionTagFlag, _ := cmd.Flags().GetString("tag")

if _, err := DownloadSolutionPackage(solutionName, solutionTagFlag, "."); err != nil {
zipPath, err := DownloadSolutionPackage(solutionName, solutionTagFlag, ".")
if err != nil {
log.Fatal(err.Error())
}

message := fmt.Sprintf("Solution %q with tag %s downloaded successfully.\n", solutionName, solutionTagFlag)
message := fmt.Sprintf("Solution %q with tag %s downloaded successfully to %v.\n", solutionName, solutionTagFlag, zipPath)
output.PrintCmdStatus(cmd, message)
}

Expand All @@ -85,7 +86,7 @@ func DownloadSolutionPackage(name string, tag string, targetPath string) (string
// if targetPath is an existing directory, place zip there; otherwise, treat as file path
fileInfo, err := os.Stat(targetPath)
if err == nil && fileInfo.IsDir() {
targetPath = filepath.Join(filepath.Dir(targetPath), name+".zip")
targetPath = filepath.Join(targetPath, name+".zip")
} else if err != nil && !errors.Is(err, os.ErrNotExist) {
return "", fmt.Errorf("failed to access target path %q: %v", targetPath, err)
} // else treat as file path, possibly overwriting existing file
Expand Down

0 comments on commit aa33378

Please sign in to comment.