Skip to content

Commit 16f2ea0

Browse files
committed
fix a couple local conn checks
1 parent 7631a66 commit 16f2ea0

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

pkg/blockcontroller/blockcontroller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func ResyncController(ctx context.Context, tabId string, blockId string, rtOpts
212212
// For shell/cmd, check connection status first
213213
if controllerName == BlockController_Shell || controllerName == BlockController_Cmd {
214214
connName := blockData.Meta.GetString(waveobj.MetaKey_Connection, "")
215-
if connName != "" {
215+
if !conncontroller.IsLocalConnName(connName) {
216216
err = CheckConnStatus(blockId)
217217
if err != nil {
218218
return fmt.Errorf("cannot start shellproc: %w", err)
@@ -362,7 +362,7 @@ func CheckConnStatus(blockId string) error {
362362
return fmt.Errorf("error getting block: %w", err)
363363
}
364364
connName := bdata.Meta.GetString(waveobj.MetaKey_Connection, "")
365-
if connName == "" {
365+
if conncontroller.IsLocalConnName(connName) {
366366
return nil
367367
}
368368
if strings.HasPrefix(connName, "wsl://") {

pkg/blockcontroller/shellcontroller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ func (bc *ShellController) getConnUnion(logCtx context.Context, remoteName strin
334334
rtn.ConnType = ConnType_Wsl
335335
rtn.WslConn = wslConn
336336
rtn.WshEnabled = wshEnabled && wslConn.WshEnabled.Load()
337-
} else if strings.HasPrefix(remoteName, "local:") || remoteName == "local" || remoteName == "" {
337+
} else if conncontroller.IsLocalConnName(remoteName) {
338338
rtn.ConnType = ConnType_Local
339339
rtn.WshEnabled = wshEnabled
340340
} else {

pkg/remote/conncontroller/conncontroller.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ var ConnServerCmdTemplate = strings.TrimSpace(
7777
"exec %s connserver",
7878
}, "\n"))
7979

80+
func IsLocalConnName(connName string) bool {
81+
return strings.HasPrefix(connName, "local:") || connName == "local" || connName == ""
82+
}
83+
8084
func GetAllConnStatus() []wshrpc.ConnStatus {
8185
globalLock.Lock()
8286
defer globalLock.Unlock()
@@ -833,7 +837,7 @@ func GetConn(opts *remote.SSHOpts) *SSHConn {
833837

834838
// Convenience function for ensuring a connection is established
835839
func EnsureConnection(ctx context.Context, connName string) error {
836-
if connName == "" {
840+
if IsLocalConnName(connName) {
837841
return nil
838842
}
839843
connOpts, err := remote.ParseOpts(connName)

0 commit comments

Comments
 (0)