diff --git a/backend/app/api/v1/backup.go b/backend/app/api/v1/backup.go index 9f649e92f..54a78dc13 100644 --- a/backend/app/api/v1/backup.go +++ b/backend/app/api/v1/backup.go @@ -302,12 +302,7 @@ func (b *BaseApi) LoadFilesFromBackup(c *gin.Context) { return } - data, err := backupService.ListFiles(req) - if err != nil { - helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) - return - } - + data := backupService.ListFiles(req) helper.SuccessWithData(c, data) } diff --git a/backend/app/service/backup.go b/backend/app/service/backup.go index 8afc978f1..8360d7827 100644 --- a/backend/app/service/backup.go +++ b/backend/app/service/backup.go @@ -40,7 +40,7 @@ type IBackupService interface { BatchDeleteRecord(ids []uint) error NewClient(backup *model.BackupAccount) (cloud_storage.CloudStorageClient, error) - ListFiles(req dto.BackupSearchFile) ([]string, error) + ListFiles(req dto.BackupSearchFile) []string MysqlBackup(db dto.CommonBackup) error PostgresqlBackup(db dto.CommonBackup) error @@ -347,14 +347,15 @@ func (u *BackupService) Update(req dto.BackupOperate) error { return nil } -func (u *BackupService) ListFiles(req dto.BackupSearchFile) ([]string, error) { +func (u *BackupService) ListFiles(req dto.BackupSearchFile) []string { + var datas []string backup, err := backupRepo.Get(backupRepo.WithByType(req.Type)) if err != nil { - return nil, err + return datas } client, err := u.NewClient(&backup) if err != nil { - return nil, err + return datas } prefix := "system_snapshot" if len(backup.BackupPath) != 0 { @@ -362,15 +363,15 @@ func (u *BackupService) ListFiles(req dto.BackupSearchFile) ([]string, error) { } files, err := client.ListObjects(prefix) if err != nil { - return nil, err + global.LOG.Debugf("load files from %s failed, err: %v", req.Type, err) + return datas } - var datas []string for _, file := range files { if len(file) != 0 { datas = append(datas, path.Base(file)) } } - return datas, nil + return datas } func (u *BackupService) NewClient(backup *model.BackupAccount) (cloud_storage.CloudStorageClient, error) { diff --git a/cmd/server/docs/docs.go b/cmd/server/docs/docs.go index 3b59e7f79..f53be5dfa 100644 --- a/cmd/server/docs/docs.go +++ b/cmd/server/docs/docs.go @@ -18630,6 +18630,9 @@ const docTemplate = `{ "type": "object", "additionalProperties": true }, + "pullImage": { + "type": "boolean" + }, "services": { "type": "object", "additionalProperties": { @@ -18701,6 +18704,9 @@ const docTemplate = `{ }, "operate": { "type": "string" + }, + "pullImage": { + "type": "boolean" } } }, @@ -18780,6 +18786,9 @@ const docTemplate = `{ "params": { "type": "object", "additionalProperties": true + }, + "pullImage": { + "type": "boolean" } } }, @@ -19330,6 +19339,9 @@ const docTemplate = `{ "params": { "type": "object", "additionalProperties": true + }, + "pullImage": { + "type": "boolean" } } }, diff --git a/cmd/server/docs/swagger.json b/cmd/server/docs/swagger.json index 1e2fc0f51..239f9a4be 100644 --- a/cmd/server/docs/swagger.json +++ b/cmd/server/docs/swagger.json @@ -18623,6 +18623,9 @@ "type": "object", "additionalProperties": true }, + "pullImage": { + "type": "boolean" + }, "services": { "type": "object", "additionalProperties": { @@ -18694,6 +18697,9 @@ }, "operate": { "type": "string" + }, + "pullImage": { + "type": "boolean" } } }, @@ -18773,6 +18779,9 @@ "params": { "type": "object", "additionalProperties": true + }, + "pullImage": { + "type": "boolean" } } }, @@ -19323,6 +19332,9 @@ "params": { "type": "object", "additionalProperties": true + }, + "pullImage": { + "type": "boolean" } } }, diff --git a/cmd/server/docs/swagger.yaml b/cmd/server/docs/swagger.yaml index 963907bb0..b79d8490f 100644 --- a/cmd/server/docs/swagger.yaml +++ b/cmd/server/docs/swagger.yaml @@ -3061,6 +3061,8 @@ definitions: params: additionalProperties: true type: object + pullImage: + type: boolean services: additionalProperties: type: string @@ -3109,6 +3111,8 @@ definitions: type: integer operate: type: string + pullImage: + type: boolean required: - installId - operate @@ -3162,6 +3166,8 @@ definitions: params: additionalProperties: true type: object + pullImage: + type: boolean required: - installId - params @@ -3532,6 +3538,8 @@ definitions: params: additionalProperties: true type: object + pullImage: + type: boolean type: object request.NginxAntiLeechUpdate: properties: diff --git a/frontend/src/views/setting/snapshot/import/index.vue b/frontend/src/views/setting/snapshot/import/index.vue index c39921efd..706fafade 100644 --- a/frontend/src/views/setting/snapshot/import/index.vue +++ b/frontend/src/views/setting/snapshot/import/index.vue @@ -74,7 +74,7 @@ const form = reactive({ const rules = reactive({ from: [Rules.requiredSelect], - name: [Rules.requiredSelect], + names: [Rules.requiredSelect], }); interface DialogProps { @@ -139,6 +139,7 @@ const loadBackups = async () => { }; const loadFiles = async () => { + form.names = []; const res = await getFilesFromBackup(form.from); fileNames.value = res.data || []; };