fix: 解决计划任务保存到第三方备份账号不生效的问题

pull/278/head
ssongliu 2 years ago committed by f2c-ci-robot[bot]
parent 791641f3e1
commit 2896409b3a

@ -118,6 +118,8 @@ func (u *CronjobService) HandleBackup(cronjob *model.Cronjob, startTime time.Tim
return "", err
}
}
itemFileDir := strings.ReplaceAll(backupDir, localDir+"/", "")
if len(record.Name) != 0 {
record.FileName = fileName
record.FileDir = backupDir
@ -125,7 +127,7 @@ func (u *CronjobService) HandleBackup(cronjob *model.Cronjob, startTime time.Tim
record.BackupType = backup.Type
if !cronjob.KeepLocal && backup.Type != "LOCAL" {
record.Source = backup.Type
record.FileDir = strings.ReplaceAll(backupDir, localDir+"/", "")
record.FileDir = itemFileDir
}
if err := backupRepo.CreateRecord(&record); err != nil {
global.LOG.Errorf("save backup record failed, err: %v", err)
@ -148,10 +150,13 @@ func (u *CronjobService) HandleBackup(cronjob *model.Cronjob, startTime time.Tim
if err != nil {
return fullPath, err
}
if _, err = client.Upload(backupDir+"/"+fileName, fullPath); err != nil {
if _, err = client.Upload(backupDir+"/"+fileName, itemFileDir+"/"+fileName); err != nil {
return fullPath, err
}
u.HandleRmExpired(backup.Type, backupDir, cronjob, client)
u.HandleRmExpired(backup.Type, itemFileDir, cronjob, client)
if cronjob.KeepLocal {
u.HandleRmExpired("LOCAL", backupDir, cronjob, client)
}
return fullPath, nil
}
@ -185,9 +190,7 @@ func (u *CronjobService) HandleRmExpired(backType, backupDir string, cronjob *mo
for i := 0; i < len(currentObjs)-int(cronjob.RetainCopies); i++ {
_, _ = backClient.Delete(currentObjs[i].(string))
}
if !cronjob.KeepLocal {
return
}
return
}
files, err := ioutil.ReadDir(backupDir)
if err != nil {

@ -64,7 +64,6 @@ declare module 'vue' {
ElSubMenu: typeof import('element-plus/es')['ElSubMenu']
ElSwitch: typeof import('element-plus/es')['ElSwitch']
ElTable: typeof import('element-plus/es')['ElTable']
ElTableColmn: typeof import('element-plus/es')['ElTableColmn']
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
ElTabPane: typeof import('element-plus/es')['ElTabPane']
ElTabs: typeof import('element-plus/es')['ElTabs']

@ -54,13 +54,13 @@ export const loadBaseDir = () => {
// backup
export const handleBackup = (params: Backup.Backup) => {
return http.post(`/settings/backup/backup`, params);
return http.post(`/settings/backup/backup`, params, 400000);
};
export const handleRecover = (params: Backup.Recover) => {
return http.post(`/settings/backup/recover`, params);
return http.post(`/settings/backup/recover`, params, 400000);
};
export const handleRecoverByUpload = (params: Backup.Recover) => {
return http.post(`/settings/backup/recover/byupload`, params);
return http.post(`/settings/backup/recover/byupload`, params, 400000);
};
export const downloadBackupRecord = (params: Backup.RecordDownload) => {
return http.download<BlobPart>(`/settings/backup/record/download`, params, { responseType: 'blob' });

@ -119,7 +119,11 @@ const acceptParams = async (params: DialogProps): Promise<void> => {
if (type.value === 'website' || type.value === 'app') {
title.value = name.value;
}
baseDir.value = `${pathRes.data}/uploads/${type.value}/${name.value}/${detailName.value}/`;
if (detailName.value) {
baseDir.value = `${pathRes.data}/uploads/${type.value}/${name.value}/${detailName.value}/`;
} else {
baseDir.value = `${pathRes.data}/uploads/${type.value}/${name.value}/`;
}
upVisiable.value = true;
search();
};
@ -198,7 +202,7 @@ const onSubmit = async () => {
MsgError(i18n.global.t('commons.msg.fileNameErr'));
return;
}
let reg = /^[a-zA-Z0-9\u4e00-\u9fa5]{1}[a-z:A-Z0-9_.\u4e00-\u9fa5-]{0,50}$/;
let reg = /^[a-zA-Z0-9\u4e00-\u9fa5]{1}[a-z:A-Z0-9_.\u4e00-\u9fa5-]{0,256}$/;
if (!reg.test(uploaderFiles.value[0]!.raw.name)) {
MsgError(i18n.global.t('commons.msg.fileNameErr'));
return;

@ -97,7 +97,7 @@ const message = {
unSupportSize: 'The uploaded file exceeds {0}M, please confirm!',
fileExist: 'The file already exists in the current folder. Repeat uploading is not supported!',
fileNameErr:
'You can upload only files whose name contains 1 to 50 characters, including English, Chinese, digits, or periods (.-_)',
'You can upload only files whose name contains 1 to 256 characters, including English, Chinese, digits, or periods (.-_)',
comfimNoNull: 'Make sure the value {0} is not empty',
},
login: {

@ -102,7 +102,7 @@ const message = {
unSupportType: '',
unSupportSize: ' {0}M',
fileExist: '',
fileNameErr: ' .-_ , 1-50 ',
fileNameErr: ' .-_ , 1-256 ',
comfimNoNull: ' {0} ',
},
login: {

Loading…
Cancel
Save