|
|
|
@ -14,6 +14,7 @@ import ( |
|
|
|
"path/filepath" |
|
|
|
"scagent/config" |
|
|
|
"strings" |
|
|
|
"time" |
|
|
|
|
|
|
|
"github.com/schollz/progressbar/v3" |
|
|
|
"go.uber.org/zap" |
|
|
|
@ -287,6 +288,17 @@ func DecompressZip(zpFname string, dirpath string) error { |
|
|
|
os.MkdirAll(filePath, os.ModePerm) |
|
|
|
continue |
|
|
|
} |
|
|
|
// 文件存在先备份再覆盖
|
|
|
|
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) |
|
|
|
} |
|
|
|
continue |
|
|
|
} |
|
|
|
// 父文件夹开始创建目录
|
|
|
|
if err := os.MkdirAll(filepath.Dir(filePath), os.ModePerm); err != nil { |
|
|
|
return fmt.Errorf("failed to make directory (%v)", err) |
|
|
|
|