|
|
@ -9,6 +9,8 @@ import ( |
|
|
"scagent/util" |
|
|
"scagent/util" |
|
|
"strings" |
|
|
"strings" |
|
|
"time" |
|
|
"time" |
|
|
|
|
|
|
|
|
|
|
|
"go.uber.org/zap" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
// FileService 提供文件传输服务
|
|
|
// FileService 提供文件传输服务
|
|
|
@ -54,6 +56,9 @@ func (f *FileService) Upload(chunk FileChunk, reply *bool) error { |
|
|
// 压缩文件
|
|
|
// 压缩文件
|
|
|
// 返回压缩包的名称
|
|
|
// 返回压缩包的名称
|
|
|
func (f *FileService) Compress(args *ZipBlock, reply *string) error { |
|
|
func (f *FileService) Compress(args *ZipBlock, reply *string) error { |
|
|
|
|
|
// 启用日志
|
|
|
|
|
|
logger := util.NewProductionLogger() |
|
|
|
|
|
defer logger.Sync() |
|
|
// 实际路径
|
|
|
// 实际路径
|
|
|
realFilePath := filepath.Join(config.G.FilePath, args.Curpath) |
|
|
realFilePath := filepath.Join(config.G.FilePath, args.Curpath) |
|
|
// zip 文件名
|
|
|
// zip 文件名
|
|
|
@ -64,7 +69,8 @@ func (f *FileService) Compress(args *ZipBlock, reply *string) error { |
|
|
go func() { |
|
|
go func() { |
|
|
util.CompressToZip(zpFileName, realFilePath, args.SelFile) |
|
|
util.CompressToZip(zpFileName, realFilePath, args.SelFile) |
|
|
taskId <- "arcok" |
|
|
taskId <- "arcok" |
|
|
// fmt.Fprintln(w, "create archive:", err)
|
|
|
// 日志输出
|
|
|
|
|
|
logger.Info("压缩文件", zap.String("filename", zpFileName), zap.String("path", realFilePath)) |
|
|
}() |
|
|
}() |
|
|
// ZIP 文件的实际路径
|
|
|
// ZIP 文件的实际路径
|
|
|
ziprl := path.Join("./sync_zips/", zpFileName) |
|
|
ziprl := path.Join("./sync_zips/", zpFileName) |
|
|
|