mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-02-13 03:50:07 +08:00
fix: fix the issue of abnormal display of backup account size (#7827)
This commit is contained in:
parent
8b30308a4b
commit
368203443f
@ -43,12 +43,21 @@ func (u *BackupRecordService) SearchRecordsWithPage(search dto.RecordSearch) (in
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
accounts, _ := backupRepo.List()
|
||||
var data []dto.BackupRecords
|
||||
for _, account := range records {
|
||||
for _, record := range records {
|
||||
var item dto.BackupRecords
|
||||
if err := copier.Copy(&item, &account); err != nil {
|
||||
if err := copier.Copy(&item, &record); err != nil {
|
||||
global.LOG.Errorf("copy backup account to dto backup info failed, err: %v", err)
|
||||
}
|
||||
for _, account := range accounts {
|
||||
if account.ID == record.DownloadAccountID {
|
||||
item.DownloadAccountID = account.ID
|
||||
item.AccountName = account.Name
|
||||
item.AccountType = account.Type
|
||||
break
|
||||
}
|
||||
}
|
||||
data = append(data, item)
|
||||
}
|
||||
return total, data, err
|
||||
@ -63,12 +72,21 @@ func (u *BackupRecordService) SearchRecordsByCronjobWithPage(search dto.RecordSe
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
accounts, _ := backupRepo.List()
|
||||
var data []dto.BackupRecords
|
||||
for _, account := range records {
|
||||
for _, record := range records {
|
||||
var item dto.BackupRecords
|
||||
if err := copier.Copy(&item, &account); err != nil {
|
||||
if err := copier.Copy(&item, &record); err != nil {
|
||||
global.LOG.Errorf("copy backup account to dto backup info failed, err: %v", err)
|
||||
}
|
||||
for _, account := range accounts {
|
||||
if account.ID == record.DownloadAccountID {
|
||||
item.DownloadAccountID = account.ID
|
||||
item.AccountName = account.Name
|
||||
item.AccountType = account.Type
|
||||
break
|
||||
}
|
||||
}
|
||||
data = append(data, item)
|
||||
}
|
||||
return total, data, err
|
||||
|
@ -492,7 +492,7 @@ func snapUpload(snap snapHelper, accounts string, file string) error {
|
||||
targetAccounts := strings.Split(accounts, ",")
|
||||
for _, item := range targetAccounts {
|
||||
snap.Task.LogStart(i18n.GetWithName("SnapUploadTo", fmt.Sprintf("[%s] %s", accountMap[item].name, path.Join("system_snapshot", path.Base(file)))))
|
||||
_, err := accountMap[item].client.Upload(source, path.Join("system_snapshot", path.Base(file)))
|
||||
_, err := accountMap[item].client.Upload(source, path.Join(accountMap[item].backupPath, "system_snapshot", path.Base(file)))
|
||||
snap.Task.LogWithStatus(i18n.GetWithName("SnapUploadRes", accountMap[item].name), err)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -1,47 +0,0 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/core/utils/files"
|
||||
)
|
||||
|
||||
type localClient struct {
|
||||
dir string
|
||||
}
|
||||
|
||||
func NewLocalClient(vars map[string]interface{}) (*localClient, error) {
|
||||
dir := loadParamFromVars("dir", vars)
|
||||
return &localClient{dir: dir}, nil
|
||||
}
|
||||
|
||||
func (c localClient) ListBuckets() ([]interface{}, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c localClient) Upload(src, target string) (bool, error) {
|
||||
targetFilePath := path.Join(c.dir, target)
|
||||
if _, err := os.Stat(path.Dir(targetFilePath)); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
if err = os.MkdirAll(path.Dir(targetFilePath), os.ModePerm); err != nil {
|
||||
return false, err
|
||||
}
|
||||
} else {
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
|
||||
if err := files.CopyFile(src, targetFilePath, false); err != nil {
|
||||
return false, fmt.Errorf("cp file failed, err: %v", err)
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (c localClient) Delete(file string) (bool, error) {
|
||||
if err := os.RemoveAll(file); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
@ -14,8 +14,6 @@ type CloudStorageClient interface {
|
||||
|
||||
func NewCloudStorageClient(backupType string, vars map[string]interface{}) (CloudStorageClient, error) {
|
||||
switch backupType {
|
||||
case constant.Local:
|
||||
return client.NewLocalClient(vars)
|
||||
case constant.S3:
|
||||
return client.NewS3Client(vars)
|
||||
case constant.OSS:
|
||||
|
@ -371,7 +371,7 @@
|
||||
<el-form-item v-if="dialogData.rowData!.type === 'directory'" :label="$t('cronjob.backupContent')">
|
||||
<el-radio-group v-model="dialogData.rowData!.isDir">
|
||||
<el-radio :value="true">{{ $t('file.dir') }}</el-radio>
|
||||
<el-radio :value="false">{{ $t('menu.file') }}</el-radio>
|
||||
<el-radio :value="false">{{ $t('menu.files') }}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
||||
|
@ -49,7 +49,7 @@
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
<LayoutContent :title="$t('menu.file')" v-loading="loading">
|
||||
<LayoutContent :title="$t('menu.files')" v-loading="loading">
|
||||
<template #prompt>
|
||||
<el-alert type="info" :closable="false">
|
||||
<template #title>
|
||||
@ -73,7 +73,7 @@
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item command="file">
|
||||
<svg-icon iconName="p-file-normal"></svg-icon>
|
||||
{{ $t('menu.file') }}
|
||||
{{ $t('menu.files') }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<div class="button-container">
|
||||
<div>
|
||||
<el-button type="primary" @click="upload('file')">
|
||||
{{ $t('commons.button.upload') }}{{ $t('menu.file') }}
|
||||
{{ $t('commons.button.upload') }}{{ $t('menu.files') }}
|
||||
</el-button>
|
||||
<el-button type="primary" @click="upload('dir')">
|
||||
{{ $t('commons.button.upload') }}{{ $t('file.dir') }}
|
||||
|
@ -48,7 +48,7 @@
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('process.openFiles')" name="openFiles">
|
||||
<el-table :data="data.openFiles" border style="width: 100%">
|
||||
<el-table-column prop="path" :label="$t('menu.file')" />
|
||||
<el-table-column prop="path" :label="$t('menu.files')" />
|
||||
<el-table-column prop="fd" label="fd" width="100px" />
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
|
@ -259,6 +259,9 @@ const beforeLeave = async (stepItem: any) => {
|
||||
loadCheckForSubmit(panelChecks, form.panelData);
|
||||
return true;
|
||||
case 'backupData':
|
||||
if (!form.appData || form.appData.length === 0) {
|
||||
return true;
|
||||
}
|
||||
if (form.backupData && form.backupData.length !== 0) {
|
||||
let backupChecks = backupRef.value.getCheckedNodes();
|
||||
loadCheckForSubmit(backupChecks, form.backupData);
|
||||
@ -497,6 +500,9 @@ const setPanelDefaultCheck = async (list: any) => {
|
||||
}
|
||||
};
|
||||
const setBackupDefaultCheck = async (list: any) => {
|
||||
if (!form.appData || form.appData.length === 0) {
|
||||
return;
|
||||
}
|
||||
for (const item of list) {
|
||||
if (item.isCheck) {
|
||||
backupRef.value.setChecked(item.id, true, true);
|
||||
|
@ -17,7 +17,7 @@
|
||||
{{ loadOperation(row.operation) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('menu.file')" show-overflow-tooltip>
|
||||
<el-table-column :label="$t('menu.files')" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ loadFileName(row.operation) }}
|
||||
</template>
|
||||
|
Loading…
x
Reference in New Issue
Block a user