fix: 计划任务排除规则改为换行切割 (#1255)

This commit is contained in:
ssongliu 2023-06-05 18:31:26 +08:00 committed by GitHub
parent 5e3e580f51
commit bb49a610a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 3 deletions

View File

@ -195,7 +195,7 @@ func handleTar(sourceDir, targetDir, name, exclusionRules string) error {
}
}
excludes := strings.Split(exclusionRules, ";")
excludes := strings.Split(exclusionRules, ",")
excludeRules := ""
for _, exclude := range excludes {
if len(exclude) == 0 {

View File

@ -2,6 +2,7 @@ package migrations
import (
"fmt"
"strings"
"time"
"github.com/1Panel-dev/1Panel/backend/app/model"
@ -364,6 +365,18 @@ var UpdateCronjobWithSecond = &gormigrate.Migration{
if err := tx.AutoMigrate(&model.Cronjob{}); err != nil {
return err
}
var jobs []model.Cronjob
if err := tx.Where("exclusion_rules != ?", "").Find(&jobs).Error; err != nil {
return err
}
for _, job := range jobs {
if strings.Contains(job.ExclusionRules, ";") {
newRules := strings.ReplaceAll(job.ExclusionRules, ";", ",")
if err := tx.Model(&model.Cronjob{}).Where("id = ?", job.ID).Update("exclusion_rules", newRules).Error; err != nil {
return err
}
}
}
return nil
},
}

View File

@ -637,7 +637,8 @@ const message = {
shell: 'Shell script',
ntp: 'Time synchronization',
website: 'Backup website',
rulesHelper: 'Compression exclusion rules (with; Is a delimiter), for example: \n*.log; *.sql',
rulesHelper:
'When there are multiple compression exclusion rules, they need to be displayed with line breaks. For example: \n*.log \n*.sql',
lastRecordTime: 'Last execution time',
all: 'All',
failedRecord: 'Failed records',

View File

@ -639,7 +639,7 @@ const message = {
shell: 'Shell 脚本',
ntp: '时间同步',
website: '备份网站',
rulesHelper: '压缩排除规则( ; 号为分隔符) \n*.log;*.sql',
rulesHelper: '当存在多个压缩排除规则时需要换行显示\n*.log \n*.sql',
lastRecordTime: '上次执行时间',
database: '备份数据库',
missBackupAccount: '未能找到备份账号',

View File

@ -210,6 +210,9 @@ const acceptParams = (params: DialogProps): void => {
changeType();
}
title.value = i18n.global.t('commons.button.' + dialogData.value.title);
if (dialogData.value?.rowData?.exclusionRules) {
dialogData.value.rowData.exclusionRules = dialogData.value.rowData.exclusionRules.replaceAll(',', '\n');
}
drawerVisiable.value = true;
checkMysqlInstalled();
loadBackups();
@ -465,6 +468,9 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
if (!formEl) return;
formEl.validate(async (valid) => {
if (!valid) return;
if (dialogData.value?.rowData?.exclusionRules) {
dialogData.value.rowData.exclusionRules = dialogData.value.rowData.exclusionRules.replaceAll('\n', ',');
}
if (!dialogData.value.rowData) return;
if (dialogData.value.title === 'create') {
await addCronjob(dialogData.value.rowData);