1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-03-13 17:24:44 +08:00

fix: 解决应用恢复导致计划任务执行失败的问题 (#3769)

This commit is contained in:
ssongliu 2024-01-31 18:47:21 +08:00 committed by GitHub
parent be53945f0e
commit 08a45e9723
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View File

@ -20,6 +20,7 @@ type ICronjobRepo interface {
Page(limit, offset int, opts ...DBOption) (int64, []model.Cronjob, error)
Create(cronjob *model.Cronjob) error
WithByJobID(id int) DBOption
WithByDbName(name string) DBOption
WithByDefaultDownload(account string) DBOption
WithByRecordDropID(id int) DBOption
WithByRecordFile(file string) DBOption
@ -117,6 +118,12 @@ func (c *CronjobRepo) WithByJobID(id int) DBOption {
}
}
func (c *CronjobRepo) WithByDbName(name string) DBOption {
return func(g *gorm.DB) *gorm.DB {
return g.Where("db_name = ?", name)
}
}
func (c *CronjobRepo) WithByDefaultDownload(account string) DBOption {
return func(g *gorm.DB) *gorm.DB {
return g.Where("default_download = ?", account)

View File

@ -303,6 +303,10 @@ func reCreateDB(dbID uint, database model.Database, oldEnv string) (*model.Datab
Password: oldPassword,
Permission: "%",
})
cronjobs, _ := cronjobRepo.List(cronjobRepo.WithByDbName(fmt.Sprintf("%v", dbID)))
for _, job := range cronjobs {
_ = cronjobRepo.Update(job.ID, map[string]interface{}{"db_name": fmt.Sprintf("%v", createDB.ID)})
}
if err != nil {
return nil, envMap, err
}