Skip to content

Commit

Permalink
Fix CheckRemote with login
Browse files Browse the repository at this point in the history
  • Loading branch information
vapopov committed Oct 26, 2024
1 parent 9fe5ed7 commit be8d322
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions lib/autoupdate/tools/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,17 @@ func (u *Updater) CheckRemote(ctx context.Context, proxyAddr string, insecure bo
// If a version of client tools has already been downloaded to
// tools directory, return that.
toolsVersion, err := CheckToolVersion(u.toolsDir)
if trace.IsNotFound(err) {
return u.localVersion, false, nil
}
if err != nil {
if err != nil && !trace.IsNotFound(err) {
return "", false, trace.Wrap(err)
}

switch {
case !resp.AutoUpdate.ToolsAutoUpdate || resp.AutoUpdate.ToolsVersion == "":
return toolsVersion, true, nil
if toolsVersion == "" {
return u.localVersion, false, nil
}
case u.localVersion == resp.AutoUpdate.ToolsVersion:
return resp.AutoUpdate.ToolsVersion, false, nil
return u.localVersion, false, nil
case resp.AutoUpdate.ToolsVersion != toolsVersion:
return resp.AutoUpdate.ToolsVersion, true, nil
}
Expand Down
2 changes: 1 addition & 1 deletion tool/tsh/common/tsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -1992,7 +1992,7 @@ func onLogin(cf *CLIConf) error {
default:
// The user is logged in and has typed in `tsh --proxy=... login`, if
// the running binary needs to be updated, update and re-exec.
if err := updateAndRun(context.Background(), tc.WebProxyAddr, tc.InsecureSkipVerify); err != nil {
if err := updateAndRun(cf.Context, tc.WebProxyAddr, tc.InsecureSkipVerify); err != nil {
return trace.Wrap(err)
}
}
Expand Down

0 comments on commit be8d322

Please sign in to comment.