Skip to content

Commit

Permalink
Fix tiup update --self with offline package
Browse files Browse the repository at this point in the history
Fix pingcap#658

Signed-off-by: lucklove <gnu.crazier@gmail.com>
  • Loading branch information
lucklove committed Aug 5, 2020
1 parent 80da63c commit f83e459
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 22 deletions.
12 changes: 11 additions & 1 deletion pkg/environment/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,17 @@ func (env *Environment) PlatformString() string {
// SelfUpdate updates TiUp.
func (env *Environment) SelfUpdate() error {
if env.v1Repo != nil {
return env.v1Repo.DownloadTiup(env.LocalPath("bin"))
if err := env.v1Repo.DownloadTiup(env.LocalPath("bin")); err != nil {
return err
}

// Cover the root.json from tiup.bar.gz
profile := localdata.InitProfile()
if err := profile.ResetMirror(Mirror(), ""); err != nil {
return err
}

return nil
}

return env.repo.DownloadTiup(env.LocalPath("bin"))
Expand Down
21 changes: 0 additions & 21 deletions pkg/repository/clone_mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,27 +306,6 @@ func cloneComponents(repo *V1Repository,
compManifests[name] = newManifest
}

// Download TiUP binary
for _, goos := range options.OSs {
for _, goarch := range options.Archs {
url := fmt.Sprintf("/tiup-%s-%s.tar.gz", goos, goarch)
dstFile := filepath.Join(targetDir, url)
tmpFile := filepath.Join(tmpDir, url)

if err := repo.Mirror().Download(url, tmpDir); err != nil {
if errors.Cause(err) == ErrNotFound {
fmt.Printf("TiUP donesn't have %s/%s, skipped\n", goos, goarch)
continue
}
return nil, err
}
// Move file to target directory if hashes pass verify.
if err := os.Rename(tmpFile, dstFile); err != nil {
return nil, err
}
}
}

return compManifests, nil
}

Expand Down

0 comments on commit f83e459

Please sign in to comment.