tq: verify connection and return error on nil
In some cases, we can end up with a panic due to a pure SSH transfer lacking any connections, but it's not clear what those cases are. Let's add some explicit checks that our connection is functional and return an error if not.
This commit is contained in:
parent
70b3fede8e
commit
91947ab05e
@ -27,6 +27,9 @@ type SSHBatchClient struct {
|
||||
|
||||
func (a *SSHBatchClient) batchInternal(args []string, batchLines []string) (int, []string, []string, error) {
|
||||
conn := a.transfer.Connection(0)
|
||||
if conn == nil {
|
||||
return 0, nil, nil, errors.Errorf(tr.Tr.Get("could not get connection for batch request"))
|
||||
}
|
||||
conn.Lock()
|
||||
defer conn.Unlock()
|
||||
err := conn.SendMessageWithLines("batch", args, batchLines)
|
||||
@ -179,6 +182,9 @@ func (a *SSHAdapter) DoTransfer(ctx interface{}, t *Transfer, cb ProgressCallbac
|
||||
authOkFunc()
|
||||
}
|
||||
conn := ctx.(*ssh.PktlineConnection)
|
||||
if conn == nil {
|
||||
return errors.Errorf(tr.Tr.Get("could not get connection for transfer"))
|
||||
}
|
||||
if a.adapterBase.direction == Upload {
|
||||
return a.upload(t, conn, cb)
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user