Browse Source

调整路径错误

master
xyiege 1 month ago
parent
commit
30b304ecc7
  1. 14
      scagent/util/fsutil.go

14
scagent/util/fsutil.go

@ -326,6 +326,11 @@ 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())
}
@ -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