fix: agent selfupdate rename .bak error
This commit is contained in:
+6
-2
@@ -1110,8 +1110,12 @@ func (a *Agent) selfUpdate() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 备份旧版本
|
// 备份旧版本 - 先去掉已有的 .bak 后缀,避免不断追加
|
||||||
backupFile := exePath + ".bak"
|
basePath := exePath
|
||||||
|
for strings.HasSuffix(basePath, ".bak") {
|
||||||
|
basePath = strings.TrimSuffix(basePath, ".bak")
|
||||||
|
}
|
||||||
|
backupFile := basePath + ".bak"
|
||||||
os.Remove(backupFile)
|
os.Remove(backupFile)
|
||||||
if err := os.Rename(exePath, backupFile); err != nil {
|
if err := os.Rename(exePath, backupFile); err != nil {
|
||||||
log.Errorf("备份旧版本失败: %v", err)
|
log.Errorf("备份旧版本失败: %v", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user