diff --git a/backend/app/service/cronjob_helper.go b/backend/app/service/cronjob_helper.go index 0c0042be0..375fe96a4 100644 --- a/backend/app/service/cronjob_helper.go +++ b/backend/app/service/cronjob_helper.go @@ -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 { diff --git a/frontend/components.d.ts b/frontend/components.d.ts index 36111373d..254206846 100644 --- a/frontend/components.d.ts +++ b/frontend/components.d.ts @@ -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'] diff --git a/frontend/src/api/modules/setting.ts b/frontend/src/api/modules/setting.ts index fb81fc3fa..9b7507299 100644 --- a/frontend/src/api/modules/setting.ts +++ b/frontend/src/api/modules/setting.ts @@ -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(`/settings/backup/record/download`, params, { responseType: 'blob' }); diff --git a/frontend/src/components/upload/index.vue b/frontend/src/components/upload/index.vue index 71128d2c9..0859c28b3 100644 --- a/frontend/src/components/upload/index.vue +++ b/frontend/src/components/upload/index.vue @@ -119,7 +119,11 @@ const acceptParams = async (params: DialogProps): Promise => { 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; diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 260619ee7..9ef9902ae 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -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: { diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 0456c9dcf..df58f0d33 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -102,7 +102,7 @@ const message = { unSupportType: '不支持当前文件类型!', unSupportSize: '上传文件超过 {0}M,请确认!', fileExist: '当前文件夹已存在该文件,不支持重复上传!', - fileNameErr: '仅支持上传名称包含英文、中文、数字或者 .-_ ,长度 1-50 位的文件', + fileNameErr: '仅支持上传名称包含英文、中文、数字或者 .-_ ,长度 1-256 位的文件', comfimNoNull: '请确认 {0} 值不为空', }, login: {