From 014b9aa5554f3338759940e1274fb7d62efd0513 Mon Sep 17 00:00:00 2001 From: xc Date: Fri, 10 Oct 2025 17:48:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E5=8E=8B=E7=BC=A9=E5=8C=85?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E8=B7=AF=E5=BE=84=E4=B8=BA=E7=9B=B8=E5=AF=B9?= =?UTF-8?q?=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aufs/core/AuFile.go | 3 ++- scagent/util/fsutil.go | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/aufs/core/AuFile.go b/aufs/core/AuFile.go index f5675e5..a771e33 100644 --- a/aufs/core/AuFile.go +++ b/aufs/core/AuFile.go @@ -53,9 +53,10 @@ func Flist(w http.ResponseWriter, r *http.Request) { // 拼装路径,并转位unix路径 newpath := filepath.ToSlash(filepath.Join(basepath, wdir)) // basepath = fmt.Sprintf("%v%v", basepath, wdir) + // 调用远程方法 var reply string - var args = Args{newpath, "dir"} + var args = Args{FilePath: newpath, Scope: "dir"} // var args = Args{"/www/wwwroot/fsc.com", "dir"} err = client.Call("FileRpcService.GetFilePath", args, &reply) // 执行完成后退出 diff --git a/scagent/util/fsutil.go b/scagent/util/fsutil.go index 705b09b..c06591a 100644 --- a/scagent/util/fsutil.go +++ b/scagent/util/fsutil.go @@ -311,6 +311,7 @@ func DecompressZip(zpFname string) error { // dest:目的地址以及压缩文件名 eg:/data/logZip/2022-12-12-log.zip // paths:需要压缩的所有文件所组成的集合 func CompressToZip(dest string, currentPath string, paths []string) error { + // fmt.Printf("currentPath:%s\n", currentPath) // fmt.Printf("paths len:%d\n", len(paths)) // fmt.Println("real path", currentPath) // 打开files 目录 @@ -341,6 +342,7 @@ func CompressToZip(dest string, currentPath string, paths []string) error { // fmt.Printf("zip src:%s\n", src) // 文件遍历 err = filepath.Walk(src, func(path string, info os.FileInfo, err error) error { + // fmt.Printf("zip path:%s\n", path) if err != nil { return err } @@ -352,7 +354,8 @@ func CompressToZip(dest string, currentPath string, paths []string) error { // 监听的工作目录作为文件的结尾,然后取相对路径 // 在zip存档中设置文件的相对路径 - header.Name, err = filepath.Rel(filepath.Dir(config.G.FilePath), path) + // 将压缩包中的绝对路径替换为相对路径 + header.Name, err = filepath.Rel(filepath.Dir(src), path) if err != nil { return err }