1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-31 22:18:07 +08:00

fix: 解决版本升级时,过滤备份失败的备份文件 (#3831)

Refs #3826
This commit is contained in:
ssongliu 2024-02-05 14:24:21 +08:00 committed by GitHub
parent 8e620172e6
commit b40087c88c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View File

@ -475,6 +475,8 @@ func (u *BackupService) loadRecordSize(records []model.BackupRecord) ([]dto.Back
datas = append(datas, item) datas = append(datas, item)
wg.Done() wg.Done()
}(i) }(i)
} else {
datas = append(datas, item)
} }
} }
wg.Wait() wg.Wait()

View File

@ -314,7 +314,7 @@ var UpdateCronjobSpec = &gormigrate.Migration{
} }
var records []model.JobRecords var records []model.JobRecords
_ = tx.Where("cronjob_id = ?", job.ID).Find(&records).Error _ = tx.Where("cronjob_id = ? AND status = ?", job.ID, constant.StatusSuccess).Find(&records).Error
for _, record := range records { for _, record := range records {
if job.Type == "snapshot" { if job.Type == "snapshot" {
var snaps []model.Snapshot var snaps []model.Snapshot
@ -329,6 +329,9 @@ var UpdateCronjobSpec = &gormigrate.Migration{
FileName: snap.Name + ".tar.gz", FileName: snap.Name + ".tar.gz",
Source: snap.From, Source: snap.From,
BackupType: snap.From, BackupType: snap.From,
BaseModel: model.BaseModel{
CreatedAt: job.CreatedAt,
},
} }
_ = tx.Create(&item).Error _ = tx.Create(&item).Error
} }
@ -344,6 +347,9 @@ var UpdateCronjobSpec = &gormigrate.Migration{
FileName: path.Base(record.File), FileName: path.Base(record.File),
Source: mapAccount[uint(job.TargetDirID)].Type, Source: mapAccount[uint(job.TargetDirID)].Type,
BackupType: mapAccount[uint(job.TargetDirID)].Type, BackupType: mapAccount[uint(job.TargetDirID)].Type,
BaseModel: model.BaseModel{
CreatedAt: job.CreatedAt,
},
} }
_ = tx.Create(&item).Error _ = tx.Create(&item).Error
continue continue
@ -357,6 +363,9 @@ var UpdateCronjobSpec = &gormigrate.Migration{
FileDir: path.Dir(strings.TrimPrefix(record.File, itemPath)), FileDir: path.Dir(strings.TrimPrefix(record.File, itemPath)),
FileName: path.Base(record.File), FileName: path.Base(record.File),
BackupType: mapAccount[uint(job.TargetDirID)].Type, BackupType: mapAccount[uint(job.TargetDirID)].Type,
BaseModel: model.BaseModel{
CreatedAt: job.CreatedAt,
},
} }
if record.FromLocal { if record.FromLocal {
item.Source = constant.Local item.Source = constant.Local