Skip to content

Commit

Permalink
Fix nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
lucklove committed Mar 5, 2021
1 parent a6dfcb9 commit da800f9
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions pkg/environment/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,33 +187,33 @@ func (env *Environment) downloadComponent(component string, version pkgver.Versi
func (env *Environment) SelectInstalledVersion(component string, ver pkgver.Version) (pkgver.Version, error) {
installed, err := env.Profile().InstalledVersions(component)
if err != nil {
return "", err
}

errInstallFirst := errors.Annotatef(ErrInstallFirst, "use `tiup install %s` to install component `%s` first", component, component)
if len(installed) < 1 {
return "", errInstallFirst
return ver, err
}

versions := []string{}
for _, v := range installed {
vi, err := env.v1Repo.ComponentVersion(component, v, true)
if err != nil {
return "", err
return ver, err
}
if vi.Yanked {
continue
}
versions = append(versions, v)
}

errInstallFirst := errors.Annotatef(ErrInstallFirst, "use `tiup install %s` to install component `%s` first", component, component)
if len(installed) == 0 {
return ver, errInstallFirst
}

if !ver.IsEmpty() {
for _, v := range versions {
if pkgver.Version(v) == ver {
return ver, nil
}
}
return "", errInstallFirst
return ver, errInstallFirst
}

sort.Slice(versions, func(i, j int) bool {
Expand All @@ -234,7 +234,7 @@ func (env *Environment) SelectInstalledVersion(component string, ver pkgver.Vers
}

if ver.IsEmpty() {
return "", errInstallFirst
return ver, errInstallFirst
}
return ver, nil
}
Expand All @@ -252,13 +252,10 @@ func (env *Environment) DownloadComponentIfMissing(component string, ver pkgver.
// download the latest version if the specific component doesn't be installed

// Check whether the specific version exist in local
needDownload := false
if ver.IsEmpty() {
ver, err = env.SelectInstalledVersion(component, ver)
needDownload = errors.Cause(err) == ErrInstallFirst
if err != nil && !needDownload {
return "", err
}
ver, err = env.SelectInstalledVersion(component, ver)
needDownload := errors.Cause(err) == ErrInstallFirst
if err != nil && !needDownload {
return "", err
}

if needDownload {
Expand Down

0 comments on commit da800f9

Please sign in to comment.