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) {
itemPath := path.Join(c.dir, prefix)
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 !info.IsDir() {
files = append(files, info.Name())

View File

@ -253,7 +253,7 @@
multiple
class="selectClass"
v-model="dialogData.rowData!.backupAccountList"
@change="changeAccount(true)"
@change="changeAccount"
>
<div v-for="item in backupOptions" :key="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 });
}
changeAccount(false);
changeAccount();
};
const changeAccount = async (handleChange: boolean) => {
const changeAccount = async () => {
accountOptions.value = [];
let isInAccounts = false;
for (const item of backupOptions.value) {
let exit = false;
let exist = false;
for (const ac of dialogData.value.rowData.backupAccountList) {
if (item.value == ac) {
exit = true;
exist = true;
break;
}
}
if (exit) {
if (exist) {
if (item.value === dialogData.value.rowData.defaultDownload) {
isInAccounts = true;
}
accountOptions.value.push(item);
}
}
if (handleChange) {
if (!isInAccounts) {
dialogData.value.rowData.defaultDownload = '';
}
};

View File

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