From b40087c88ccbed28db3f8ffaa17299b1d528ba14 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Mon, 5 Feb 2024 14:24:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8D=87=E7=BA=A7=E6=97=B6=EF=BC=8C=E8=BF=87=E6=BB=A4=E5=A4=87?= =?UTF-8?q?=E4=BB=BD=E5=A4=B1=E8=B4=A5=E7=9A=84=E5=A4=87=E4=BB=BD=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20(#3831)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs #3826 --- backend/app/service/backup.go | 2 ++ backend/init/migration/migrations/v_1_9.go | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/backend/app/service/backup.go b/backend/app/service/backup.go index 169d4276b..0e06c80e7 100644 --- a/backend/app/service/backup.go +++ b/backend/app/service/backup.go @@ -475,6 +475,8 @@ func (u *BackupService) loadRecordSize(records []model.BackupRecord) ([]dto.Back datas = append(datas, item) wg.Done() }(i) + } else { + datas = append(datas, item) } } wg.Wait() diff --git a/backend/init/migration/migrations/v_1_9.go b/backend/init/migration/migrations/v_1_9.go index 00c1bc3c5..5c21f4872 100644 --- a/backend/init/migration/migrations/v_1_9.go +++ b/backend/init/migration/migrations/v_1_9.go @@ -314,7 +314,7 @@ var UpdateCronjobSpec = &gormigrate.Migration{ } 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 { if job.Type == "snapshot" { var snaps []model.Snapshot @@ -329,6 +329,9 @@ var UpdateCronjobSpec = &gormigrate.Migration{ FileName: snap.Name + ".tar.gz", Source: snap.From, BackupType: snap.From, + BaseModel: model.BaseModel{ + CreatedAt: job.CreatedAt, + }, } _ = tx.Create(&item).Error } @@ -344,6 +347,9 @@ var UpdateCronjobSpec = &gormigrate.Migration{ FileName: path.Base(record.File), Source: mapAccount[uint(job.TargetDirID)].Type, BackupType: mapAccount[uint(job.TargetDirID)].Type, + BaseModel: model.BaseModel{ + CreatedAt: job.CreatedAt, + }, } _ = tx.Create(&item).Error continue @@ -357,6 +363,9 @@ var UpdateCronjobSpec = &gormigrate.Migration{ FileDir: path.Dir(strings.TrimPrefix(record.File, itemPath)), FileName: path.Base(record.File), BackupType: mapAccount[uint(job.TargetDirID)].Type, + BaseModel: model.BaseModel{ + CreatedAt: job.CreatedAt, + }, } if record.FromLocal { item.Source = constant.Local