fix: 解决快照上传失败的问题 (#2270)

This commit is contained in:
ssongliu 2023-09-13 14:08:16 +08:00 committed by GitHub
parent 9837c60a88
commit 47cfa0c730
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 10 deletions

View file

@ -194,7 +194,8 @@ func snapUpload(snap snapHelper, account string, file string) {
_ = snapshotRepo.UpdateStatus(snap.Status.ID, map[string]interface{}{"upload": err.Error()})
return
}
target := path.Join(backup.BackupPath, "system_snapshot", path.Base(file))
target := path.Join(strings.TrimPrefix(backup.BackupPath, "/"), "system_snapshot", path.Base(file))
global.LOG.Debugf("start upload snapshot to %s, dir: %s", backup.Type, target)
if _, err := client.Upload(source, target); err != nil {
snap.Status.Upload = err.Error()
_ = snapshotRepo.UpdateStatus(snap.Status.ID, map[string]interface{}{"upload": err.Error()})

View file

@ -1,10 +1,10 @@
<template>
<div v-loading="loading">
<div>
<el-drawer v-model="drawerVisiable" size="30%">
<template #header>
<DrawerHeader :header="$t('setting.importSnapshot')" :back="handleClose" />
</template>
<el-form ref="formRef" label-position="top" :model="form" :rules="rules">
<el-form ref="formRef" label-position="top" :model="form" :rules="rules" v-loading="loading">
<el-row type="flex" justify="center">
<el-col :span="22">
<el-form-item :label="$t('setting.backupAccount')" prop="from">
@ -101,13 +101,20 @@ const submitImport = async (formEl: FormInstance | undefined) => {
};
const loadBackups = async () => {
const res = await getBackupList();
backupOptions.value = [];
for (const item of res.data) {
if (item.type !== 'LOCAL' && item.id !== 0) {
backupOptions.value.push({ label: i18n.global.t('setting.' + item.type), value: item.type });
}
}
loading.value = true;
await getBackupList()
.then((res) => {
loading.value = false;
backupOptions.value = [];
for (const item of res.data) {
if (item.type !== 'LOCAL' && item.id !== 0) {
backupOptions.value.push({ label: i18n.global.t('setting.' + item.type), value: item.type });
}
}
})
.catch(() => {
loading.value = false;
});
};
const loadFiles = async () => {