@@ -199,17 +199,18 @@ func createLink(ctx context.Context, installTask *task.Task, app model.App, appI
199
199
}
200
200
case constant .AppRedis :
201
201
if password , ok := params ["PANEL_REDIS_ROOT_PASSWORD" ]; ok {
202
+ authParam := dto.RedisAuthParam {
203
+ RootPassword : "" ,
204
+ }
202
205
if password != "" {
203
- authParam := dto.RedisAuthParam {
204
- RootPassword : password .(string ),
205
- }
206
- authByte , err := json .Marshal (authParam )
207
- if err != nil {
208
- return err
209
- }
210
- appInstall .Param = string (authByte )
206
+ authParam .RootPassword = password .(string )
207
+ database .Password = password .(string )
208
+ }
209
+ authByte , err := json .Marshal (authParam )
210
+ if err != nil {
211
+ return err
211
212
}
212
- database . Password = password .( string )
213
+ appInstall . Param = string ( authByte )
213
214
}
214
215
}
215
216
return databaseRepo .Create (ctx , database )
@@ -558,11 +559,23 @@ func upgradeInstall(req request.AppInstallUpgrade) error {
558
559
)
559
560
backUpApp := func (t * task.Task ) error {
560
561
if req .Backup {
561
- backupRecord , err := NewIBackupService ().AppBackup (dto.CommonBackup {Name : install .App .Key , DetailName : install .Name })
562
- if err != nil {
562
+ backupService := NewIBackupService ()
563
+ fileName := fmt .Sprintf ("upgrade_backup_%s_%s.tar.gz" , install .Name , time .Now ().Format (constant .DateTimeSlimLayout )+ common .RandStrAndNum (5 ))
564
+ backupRecord , err := backupService .AppBackup (dto.CommonBackup {Name : install .App .Key , DetailName : install .Name , FileName : fileName })
565
+ if err == nil {
566
+ backups , _ := backupService .ListAppRecords (install .App .Key , install .Name , "upgrade_backup" )
567
+ if len (backups ) > 3 {
568
+ backupsToDelete := backups [:len (backups )- 3 ]
569
+ var deleteIDs []uint
570
+ for _ , backup := range backupsToDelete {
571
+ deleteIDs = append (deleteIDs , backup .ID )
572
+ }
573
+ _ = backupService .BatchDeleteRecord (deleteIDs )
574
+ }
575
+ backupFile = path .Join (global .CONF .System .Backup , backupRecord .FileDir , backupRecord .FileName )
576
+ } else {
563
577
return buserr .WithNameAndErr ("ErrAppBackup" , install .Name , err )
564
578
}
565
- backupFile = path .Join (global .CONF .System .Backup , backupRecord .FileDir , backupRecord .FileName )
566
579
}
567
580
return nil
568
581
}
@@ -1390,7 +1403,7 @@ func handleInstalled(appInstallList []model.AppInstall, updated bool, sync bool)
1390
1403
}
1391
1404
1392
1405
for _ , installed := range appInstallList {
1393
- if updated && (installed . App . Type == "php" || installed . Status == constant . Installing || ( installed . App . Key == constant . AppMysql && installed . Version == "5.6.51" ) ) {
1406
+ if updated && ignoreUpdate (installed ) {
1394
1407
continue
1395
1408
}
1396
1409
if sync && ! doNotNeedSync (installed ) {
@@ -1691,3 +1704,28 @@ func isHostModel(dockerCompose string) bool {
1691
1704
}
1692
1705
return false
1693
1706
}
1707
+
1708
+ func getMajorVersion (version string ) string {
1709
+ parts := strings .Split (version , "." )
1710
+ if len (parts ) >= 2 {
1711
+ return parts [0 ] + "." + parts [1 ]
1712
+ }
1713
+ return version
1714
+ }
1715
+
1716
+ func ignoreUpdate (installed model.AppInstall ) bool {
1717
+ if installed .App .Type == "php" || installed .Status == constant .Installing {
1718
+ return true
1719
+ }
1720
+ if installed .App .Key == constant .AppMysql {
1721
+ majorVersion := getMajorVersion (installed .Version )
1722
+ appDetails , _ := appDetailRepo .GetBy (appDetailRepo .WithAppId (installed .App .ID ))
1723
+ for _ , appDetail := range appDetails {
1724
+ if strings .HasPrefix (appDetail .Version , majorVersion ) && common .CompareVersion (appDetail .Version , installed .Version ) {
1725
+ return false
1726
+ }
1727
+ }
1728
+ return true
1729
+ }
1730
+ return false
1731
+ }
0 commit comments