Compare commits

...

2 Commits

Author SHA1 Message Date
xyiege 2ec36400c3 修正路径错误 8 months ago
xyiege 30b304ecc7 调整路径错误 8 months ago
  1. 16
      scagent/util/fsutil.go

16
scagent/util/fsutil.go

@ -326,11 +326,16 @@ func CompressToZip(dest string, currentPath string, paths []string) error {
if dir, err := os.Getwd(); err == nil {
filesPath = dir + "/sync_zips/"
}
// 目录格式 2025/10
dirpath := fmt.Sprintf("%d/%02d", time.Now().Year(), time.Now().Month())
// 组织目录路径
filesPath = filepath.Join(filesPath, dirpath)
// 创建目录
if err := os.MkdirAll(filesPath, os.ModePerm); err != nil {
fmt.Println(err.Error())
}
// ToSlash 过滤windows的斜杠引起的bug
zfile, err := os.Create(path.Join("./sync_zips", "/", dest))
zfile, err := os.Create(path.Join("./sync_zips", filesPath, dest))
if err != nil {
return err
}
@ -338,15 +343,6 @@ func CompressToZip(dest string, currentPath string, paths []string) error {
zipWriter := zip.NewWriter(zfile)
defer zipWriter.Close()
// 目录格式 2025/10
dirpath := fmt.Sprintf("%d/%02d", time.Now().Year(), time.Now().Month())
// 组织目录路径
filesPath = filepath.Join(filesPath, dirpath)
// 创建目录
if err := os.MkdirAll(filesPath, os.ModePerm); err != nil {
return err
}
// 遍历带压缩的目录信息
for _, src := range paths {
// 替换文件名,并且去除前后 "\" 或 "/"

Loading…
Cancel
Save