From aa093413848a070c2353bc9c6ef19377079551d6 Mon Sep 17 00:00:00 2001 From: xc Date: Thu, 23 Oct 2025 11:53:16 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=9C=E7=A8=8B=E8=B0=83=E7=94=A8=E8=A7=A3?= =?UTF-8?q?=E5=8E=8B=E7=BC=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scagent/core/UpFile.go | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/scagent/core/UpFile.go b/scagent/core/UpFile.go index 7d708c5..5781d59 100644 --- a/scagent/core/UpFile.go +++ b/scagent/core/UpFile.go @@ -37,21 +37,16 @@ func (f *UpFileService) SendFileInfo(info FileInfo, reply *string) error { // } // 提取路径 /www/wwwroot/bidemo.com/BIU_20250918_183144.zip - // fmt.Printf("SendFileInfo fileName: %s\n", info.FileName) dirPath := filepath.Dir(info.FileName) logger.Info("SendFileInfo", zap.String("dirPath", dirPath)) - // *reply = fmt.Sprintf("folder: %s is exists", dirPath) // 检查文件夹是否存在 if _, err := os.Stat(dirPath); os.IsNotExist(err) { // 文件夹不存在,创建它 if err := os.MkdirAll(dirPath, 0755); err != nil { logger.Error("SendFileInfo mkdir failed", zap.Error(err)) - // *reply = fmt.Sprintf("mkdir folder: %s failed", dirPath) - // return err } } - // *reply = fmt.Sprintf("folder: %s is exists", dirPath) // 返回true的字符串 *reply = "true" return nil @@ -88,3 +83,22 @@ func (f *UpFileService) SendFileChunk(chunk FileChunk, reply *bool) error { *reply = true return nil } + +// 解压缩文件 +// info.FileName 压缩包全路径 +func (f *UpFileService) UnzipArchive(info FileInfo, reply *string) error { + // 日志 + logger := util.NewProductionLogger() + defer logger.Sync() + // 解压缩文件 + ret := make(chan string) + go func() { + util.DecompressZip(info.FileName) + ret <- "uzok" + }() + // 返回true的字符串 + if retMsg := <-ret; retMsg == "uzok" { + *reply = retMsg + } + return nil +}