Browse Source

提交成功后刷新

master
xyiege 1 month ago
parent
commit
283d55b27a
  1. 11
      scagent/util/fsutil.go

11
scagent/util/fsutil.go

@ -14,7 +14,6 @@ import (
"path/filepath" "path/filepath"
"scagent/config" "scagent/config"
"strings" "strings"
"time"
"github.com/schollz/progressbar/v3" "github.com/schollz/progressbar/v3"
"go.uber.org/zap" "go.uber.org/zap"
@ -304,16 +303,6 @@ func DecompressZip(zpFname string, dirpath string) error {
return fmt.Errorf("failed to open file in zip (%v)", err) return fmt.Errorf("failed to open file in zip (%v)", err)
} }
defer fileInArchive.Close() defer fileInArchive.Close()
// 检查文件是否存在,存在的话先备份
if _, err := os.Stat(filePath); err == nil {
// 当前时间
currentTime := time.Now().Format("20060102_150405")
// 备份文件
backupPath := filePath + currentTime + "_bak"
if err := os.Rename(filePath, backupPath); err != nil {
return fmt.Errorf("failed to backup file (%v)", err)
}
}
// 复制文件到目标路径 // 复制文件到目标路径
if _, err := io.Copy(dstFile, fileInArchive); err != nil { if _, err := io.Copy(dstFile, fileInArchive); err != nil {
return fmt.Errorf("failed to copy file in zip (%v)", err) return fmt.Errorf("failed to copy file in zip (%v)", err)

Loading…
Cancel
Save