mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 14:50:55 +03:00
ssh commands: improve command ended detection
Sometime we can have this error: read |0: file already closed reading from the command standard error, this means that the command is already finished so we don't need to do nothing. This happen randomically while running the test cases on travis.
This commit is contained in:
@@ -5,7 +5,6 @@ os:
|
|||||||
- osx
|
- osx
|
||||||
|
|
||||||
go:
|
go:
|
||||||
- "1.12.x"
|
|
||||||
- "1.13.x"
|
- "1.13.x"
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ Regularly the test cases are manually executed and pass on Windows. Other UNIX v
|
|||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- Go 1.12 or higher as build only dependency.
|
- Go 1.13 or higher as build only dependency.
|
||||||
- A suitable SQL server or key/value store to use as data provider: PostreSQL 9.4+ or MySQL 5.6+ or SQLite 3.x or bbolt 1.3.x
|
- A suitable SQL server or key/value store to use as data provider: PostreSQL 9.4+ or MySQL 5.6+ or SQLite 3.x or bbolt 1.3.x
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|||||||
@@ -261,7 +261,8 @@ func (c *sshCommand) executeSystemCommand(command systemCommand) error {
|
|||||||
w, e := transfer.copyFromReaderToWriter(c.connection.channel.Stderr(), stderr, 0)
|
w, e := transfer.copyFromReaderToWriter(c.connection.channel.Stderr(), stderr, 0)
|
||||||
c.connection.Log(logger.LevelDebug, logSenderSSH, "command: %#v, copy from sdterr to remote command ended, written: %v err: %v",
|
c.connection.Log(logger.LevelDebug, logSenderSSH, "command: %#v, copy from sdterr to remote command ended, written: %v err: %v",
|
||||||
c.connection.command, w, e)
|
c.connection.command, w, e)
|
||||||
if e != nil || w > 0 {
|
// os.ErrClosed means that the command is finished so we don't need to to nothing
|
||||||
|
if (e != nil && !errors.Is(e, os.ErrClosed)) || w > 0 {
|
||||||
once.Do(closeCmdOnError)
|
once.Do(closeCmdOnError)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|||||||
Reference in New Issue
Block a user