Browse Source

修正发送文件路径错误的异常

master
xyiege 1 month ago
parent
commit
b1d7f9c184
  1. 4
      scagent/core/FileRpc.go
  2. 5
      scagent/util/fsutil.go

4
scagent/core/FileRpc.go

@ -61,8 +61,10 @@ func (f *FileService) Compress(args *ZipBlock, reply *string) error {
// 日志输出
logger.Info("压缩文件", zap.String("filename", zpFileName), zap.String("path", realFilePath))
}()
// 年月格式的目录
dirpath := fmt.Sprintf("%d/%02d", time.Now().Year(), time.Now().Month())
// ZIP 文件的实际路径
ziprl := path.Join(config.G.FilePath, "/sync_zips", zpFileName)
ziprl := path.Join(config.G.FilePath, "/sync_zips", dirpath, zpFileName)
// zip 创建成功后
rest := <-taskId
// 如果压缩包生成成功以后再执行

5
scagent/util/fsutil.go

@ -335,7 +335,7 @@ func CompressToZip(dest string, currentPath string, paths []string) error {
fmt.Println(err.Error())
}
// ToSlash 过滤windows的斜杠引起的bug
zfile, err := os.Create(path.Join(filesPath, dest))
zfile, err := os.Create(path.Join("./sync_zips", "/", dest))
if err != nil {
return err
}
@ -409,7 +409,8 @@ func CompressToZip(dest string, currentPath string, paths []string) error {
}
}
// 存到指定位置
os.Rename(dest, path.Join("./sync_zips/", dest))
// os.Rename(dest, path.Join("./sync_zips/", dest))
os.Rename(path.Join("./sync_zips/", dest), path.Join(filesPath, dest))
return nil
}

Loading…
Cancel
Save