fix: Fix the problem of abnormal recovery of the application state (#8512)

This commit is contained in:
ssongliu 2025-04-29 15:58:21 +08:00 committed by GitHub
parent 0b581b748b
commit 8bd712d891
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View file

@ -340,7 +340,13 @@ func snapAppImage(snap snapHelper, req dto.SnapshotCreate, targetDir string) err
var appInstalls []model.AppInstall
_ = snap.snapAgentDB.Where("1 = 1").Find(&appInstalls).Error
for _, item := range appInstalls {
_ = snap.snapAgentDB.Where("id = ?", item.ID).Updates(map[string]interface{}{"status": constant.StatusWaitingRestart}).Error
if err := snap.snapAgentDB.
Model(&model.AppInstall{}).
Where("id = ?", item.ID).
Updates(map[string]interface{}{"status": constant.StatusWaitingRestart}).
Error; err != nil {
global.LOG.Errorf("update app %s status failed, err: %v", item.Name, err)
}
}
var imageList []string

View file

@ -170,6 +170,7 @@ func (u *UpgradeService) Upgrade(req dto.Upgrade) error {
global.LOG.Info("upgrade successful!")
go writeLogs(req.Version)
_ = settingRepo.Update("SystemVersion", req.Version)
_ = global.AgentDB.Model(&model.Setting{}).Where("key = ?", "SystemVersion").Updates(map[string]interface{}{"value": req.Version}).Error
global.CONF.Base.Version = req.Version
_ = settingRepo.Update("SystemStatus", "Free")