Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #41 from wanderxjtu/main
Browse files Browse the repository at this point in the history
only show successfully installed version in kusionup version selection list
  • Loading branch information
SparkYuan authored Jun 25, 2024
2 parents 0f9a408 + 61ed1b5 commit bc8982b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
9 changes: 5 additions & 4 deletions pkg/commands/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ func install(source, version string) error {
return nil
}

if err := os.MkdirAll(targetDir, 0o755); err != nil {
return err
}

// Get download url
rs := registedReleaseSources[source]

Expand All @@ -135,6 +131,11 @@ func install(source, version string) error {
return fmt.Errorf("server returned %v checking size of %v", http.StatusText(res.StatusCode), downloadURL)
}

// Create download dir
if err := os.MkdirAll(targetDir, 0o755); err != nil {
return err
}

// Download
base := path.Base(downloadURL)
archiveFile := filepath.Join(targetDir, base)
Expand Down
9 changes: 6 additions & 3 deletions pkg/commands/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package commands

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -66,7 +65,7 @@ type goVer struct {
}

func listKusionVers() ([]goVer, error) {
files, err := ioutil.ReadDir(KusionupDir())
files, err := os.ReadDir(KusionupDir())
if err != nil {
return nil, err
}
Expand All @@ -79,7 +78,11 @@ func listKusionVers() ([]goVer, error) {
var vers []goVer

for _, file := range files {
if strings.HasPrefix(file.Name(), "kusion") {
if file.IsDir() && strings.HasPrefix(file.Name(), "kusion") {
if _, err := os.Stat(KusionupDir(file.Name(), unpackedOkay)); err != nil {
// only list successfully unpacked verions
continue
}
vers = append(vers, goVer{
Ver: strings.TrimPrefix(file.Name(), "kusion-"),
Current: current == file.Name(),
Expand Down

0 comments on commit bc8982b

Please sign in to comment.