mirror of
https://github.com/appleboy/drone-scp.git
synced 2026-06-04 18:23:59 +08:00
refactor: refactor system type checks in SSH commands
- Remove `uname` check for system type from `removeAllDestFile` function. - Add `ver` check for SSH command in `Exec` function. - Remove `uname` check for system type from `Exec` function. Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
This commit is contained in:
@@ -169,11 +169,6 @@ func (p *Plugin) removeAllDestFile() error {
|
||||
systemType = "windows"
|
||||
}
|
||||
|
||||
_, _, _, err = ssh.Run("uname", p.Config.CommandTimeout)
|
||||
if err == nil {
|
||||
systemType = "unix"
|
||||
}
|
||||
|
||||
// remove tar file
|
||||
err = p.removeDestFile(systemType, ssh)
|
||||
if err != nil {
|
||||
@@ -309,17 +304,12 @@ func (p *Plugin) Exec() error {
|
||||
},
|
||||
}
|
||||
|
||||
_, _, _, err := ssh.Run("ver", p.Config.CommandTimeout)
|
||||
systemType := "unix"
|
||||
_, _, _, err := ssh.Run("ver", p.Config.CommandTimeout)
|
||||
if err == nil {
|
||||
systemType = "windows"
|
||||
}
|
||||
|
||||
_, _, _, err = ssh.Run("uname", p.Config.CommandTimeout)
|
||||
if err == nil {
|
||||
systemType = "unix"
|
||||
}
|
||||
|
||||
// upload file to the tmp path
|
||||
p.DestFile = fmt.Sprintf("%s%s", p.Config.TarTmpPath, p.DestFile)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user