mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 02:38:17 +08:00
[FIX] fix creat dst tgz file error
This commit is contained in:
parent
56732d3d1d
commit
f9fe2115d0
@ -22,6 +22,9 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/goodrain/rainbond/pkg/util"
|
||||
|
||||
"github.com/goodrain/rainbond/pkg/event"
|
||||
)
|
||||
@ -43,6 +46,14 @@ func CopyFileWithProgress(src, dst string, logger event.Logger) error {
|
||||
}
|
||||
return err
|
||||
}
|
||||
// 验证并创建目标目录
|
||||
dir := filepath.Dir(dst)
|
||||
if err := util.CheckAndCreateDir(dir); err != nil {
|
||||
if logger != nil {
|
||||
logger.Error("检测并创建目标文件目录失败", map[string]string{"step": "share"})
|
||||
}
|
||||
return err
|
||||
}
|
||||
// 先删除文件如果存在
|
||||
os.RemoveAll(dst)
|
||||
dstFile, err := os.OpenFile(dst, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0644)
|
||||
|
@ -31,7 +31,7 @@ func init() {
|
||||
}
|
||||
func TestCopyFileWithProgress(t *testing.T) {
|
||||
logger := event.GetManager().GetLogger("system")
|
||||
if err := CopyFileWithProgress("/tmp/src.tgz", "/tmp/desc1.tgz", logger); err != nil {
|
||||
if err := CopyFileWithProgress("/tmp/src.tgz", "/tmp/abc/desc1.tgz", logger); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -26,11 +26,11 @@ import (
|
||||
|
||||
func TestFTPUp(t *testing.T) {
|
||||
logger := event.GetManager().GetLogger("system")
|
||||
ftp := NewFTPConnManager(logger, "goodrain-admin", "goodrain123465", "139.196.88.57", 10021)
|
||||
ftp := NewFTPConnManager(logger, "goodrain-admin", "goodrain123465", "139.196.88.57", "10021")
|
||||
defer ftp.FTP.Close()
|
||||
upfile := "/Users/pujielan/Downloads/http.conf"
|
||||
if err := ftp.FTPLogin(logger); err != nil {
|
||||
t.Fatal(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
path := "app-publish/application/"
|
||||
curPath, err := ftp.FTPCWD(logger, path)
|
||||
|
Loading…
Reference in New Issue
Block a user