Browse Source

pref: 优化同步快照返回信息 (#3773)

pull/3776/head
ssongliu 10 months ago committed by GitHub
parent
commit
a4cfb587d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 7
      backend/app/api/v1/backup.go
  2. 15
      backend/app/service/backup.go
  3. 12
      cmd/server/docs/docs.go
  4. 12
      cmd/server/docs/swagger.json
  5. 8
      cmd/server/docs/swagger.yaml
  6. 3
      frontend/src/views/setting/snapshot/import/index.vue

7
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)
}

15
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) {

12
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"
}
}
},

12
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"
}
}
},

8
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:

3
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 || [];
};

Loading…
Cancel
Save