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

pref: 优化计划任务备份账号切换逻辑 (#3758)

This commit is contained in:
ssongliu 2024-01-31 15:08:03 +08:00 committed by GitHub
parent 83dda25591
commit 3804942ae4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 11 deletions

View File

@ -81,8 +81,11 @@ func (c localClient) Download(src, target string) (bool, error) {
} }
func (c localClient) ListObjects(prefix string) ([]string, error) { func (c localClient) ListObjects(prefix string) ([]string, error) {
itemPath := path.Join(c.dir, prefix)
var files []string var files []string
itemPath := path.Join(c.dir, prefix)
if _, err := os.Stat(itemPath); err != nil {
return files, nil
}
if err := filepath.Walk(itemPath, func(path string, info os.FileInfo, err error) error { if err := filepath.Walk(itemPath, func(path string, info os.FileInfo, err error) error {
if !info.IsDir() { if !info.IsDir() {
files = append(files, info.Name()) files = append(files, info.Name())

View File

@ -253,7 +253,7 @@
multiple multiple
class="selectClass" class="selectClass"
v-model="dialogData.rowData!.backupAccountList" v-model="dialogData.rowData!.backupAccountList"
@change="changeAccount(true)" @change="changeAccount"
> >
<div v-for="item in backupOptions" :key="item.label"> <div v-for="item in backupOptions" :key="item.label">
<el-option :value="item.value" :label="item.label" /> <el-option :value="item.value" :label="item.label" />
@ -523,24 +523,28 @@ const loadBackups = async () => {
} }
backupOptions.value.push({ label: i18n.global.t('setting.' + item.type), value: item.type }); backupOptions.value.push({ label: i18n.global.t('setting.' + item.type), value: item.type });
} }
changeAccount(false); changeAccount();
}; };
const changeAccount = async (handleChange: boolean) => { const changeAccount = async () => {
accountOptions.value = []; accountOptions.value = [];
let isInAccounts = false;
for (const item of backupOptions.value) { for (const item of backupOptions.value) {
let exit = false; let exist = false;
for (const ac of dialogData.value.rowData.backupAccountList) { for (const ac of dialogData.value.rowData.backupAccountList) {
if (item.value == ac) { if (item.value == ac) {
exit = true; exist = true;
break; break;
} }
} }
if (exit) { if (exist) {
if (item.value === dialogData.value.rowData.defaultDownload) {
isInAccounts = true;
}
accountOptions.value.push(item); accountOptions.value.push(item);
} }
} }
if (handleChange) { if (!isInAccounts) {
dialogData.value.rowData.defaultDownload = ''; dialogData.value.rowData.defaultDownload = '';
} }
}; };

View File

@ -296,18 +296,25 @@ const loadBackups = async () => {
const changeAccount = async () => { const changeAccount = async () => {
accountOptions.value = []; accountOptions.value = [];
let isInAccounts = false;
for (const item of backupOptions.value) { for (const item of backupOptions.value) {
let exit = false; let exist = false;
for (const ac of snapInfo.fromAccounts) { for (const ac of snapInfo.fromAccounts) {
if (item.value == ac) { if (item.value == ac) {
exit = true; exist = true;
break; break;
} }
} }
if (exit) { if (exist) {
if (item.value === snapInfo.defaultDownload) {
isInAccounts = true;
}
accountOptions.value.push(item); accountOptions.value.push(item);
} }
} }
if (!isInAccounts) {
snapInfo.defaultDownload = '';
}
}; };
const batchDelete = async (row: Setting.SnapshotInfo | null) => { const batchDelete = async (row: Setting.SnapshotInfo | null) => {