From 93a4a40374c95c2e1ba9a72ba8146416acbadd43 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Mon, 29 Apr 2024 18:21:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B7=A5=E5=85=B7sftp=E5=A4=8D=E5=88=B6?= =?UTF-8?q?=E5=88=B0=E8=BF=9C=E7=A8=8B=E4=B8=8D=E5=88=9B=E5=BB=BA=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=B9/=E5=A4=8D=E5=88=B6=E5=88=B0=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E4=B8=8D=E5=A4=87=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/framework/utils/ssh/ssh.go | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/framework/utils/ssh/ssh.go b/src/framework/utils/ssh/ssh.go index 1cb41b59..d25c686f 100644 --- a/src/framework/utils/ssh/ssh.go +++ b/src/framework/utils/ssh/ssh.go @@ -431,15 +431,15 @@ func (s *SSHClientSFTP) CopyFileRemoteToLocal(remotePath, localPath string) erro } // 如果目标文件已经存在,先将目标文件重命名 - if info, err := os.Stat(localPath); err == nil && !info.IsDir() { - ext := filepath.Ext(localPath) - name := localPath[0 : len(localPath)-len(ext)] - newName := fmt.Sprintf("%s-%s%s", name, time.Now().Format("20060102_150405"), ext) - err := os.Rename(localPath, newName) - if err != nil { - return err - } - } + // if info, err := os.Stat(localPath); err == nil && !info.IsDir() { + // ext := filepath.Ext(localPath) + // name := localPath[0 : len(localPath)-len(ext)] + // newName := fmt.Sprintf("%s-%s%s", name, time.Now().Format("20060102_150405"), ext) + // err := os.Rename(localPath, newName) + // if err != nil { + // return err + // } + // } // 创建本地文件 localFile, err := os.Create(localPath) @@ -468,12 +468,6 @@ func (s *SSHClientSFTP) CopyFileLocalToRemote(localPath, remotePath string) erro } defer localFile.Close() - // 创建远程目录 - if err := s.Client.MkdirAll(filepath.Dir(remotePath)); err != nil { - logger.Errorf("CopyFileLocalToRemote failed to creating remote directory %s: => %s", remotePath, err.Error()) - return err - } - // 创建远程文件 remoteFile, err := s.Client.Create(remotePath) if err != nil {