fix: 解决计划任务记录删除时文件被误删问题 (#3777)

This commit is contained in:
ssongliu 2024-02-01 18:05:40 +08:00 committed by GitHub
parent d82086ce4a
commit c758c1ce87
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 23 additions and 19 deletions

View File

@ -53,6 +53,7 @@ type CronjobDownload struct {
}
type CronjobClean struct {
IsDelete bool `json:"isDelete"`
CleanData bool `json:"cleanData"`
CronjobID uint `json:"cronjobID" validate:"required"`
}

View File

@ -108,7 +108,8 @@ func (u *CronjobService) CleanRecord(req dto.CronjobClean) error {
} else {
u.removeExpiredLog(cronjob)
}
} else {
}
if req.IsDelete {
records, _ := backupRepo.ListRecord(backupRepo.WithByCronID(cronjob.ID))
for _, records := range records {
records.CronjobID = 0
@ -224,7 +225,7 @@ func (u *CronjobService) Delete(req dto.CronjobBatchDelete) error {
global.Cron.Remove(cron.EntryID(idItem))
}
global.LOG.Infof("stop cronjob entryID: %s", cronjob.EntryIDs)
if err := u.CleanRecord(dto.CronjobClean{CronjobID: id, CleanData: req.CleanData}); err != nil {
if err := u.CleanRecord(dto.CronjobClean{CronjobID: id, CleanData: req.CleanData, IsDelete: true}); err != nil {
return err
}
if err := cronjobRepo.Delete(commonRepo.WithByID(id)); err != nil {

View File

@ -14924,6 +14924,9 @@ const docTemplate = `{
},
"cronjobID": {
"type": "integer"
},
"isDelete": {
"type": "boolean"
}
}
},

View File

@ -14917,6 +14917,9 @@
},
"cronjobID": {
"type": "integer"
},
"isDelete": {
"type": "boolean"
}
}
},

View File

@ -573,6 +573,8 @@ definitions:
type: boolean
cronjobID:
type: integer
isDelete:
type: boolean
required:
- cronjobID
type: object

View File

@ -322,16 +322,7 @@ const buttons = [
{
label: i18n.global.t('commons.button.recover'),
click: (row: File.File) => {
if (type.value !== 'app') {
onRecover(row);
} else {
ElMessageBox.confirm(i18n.global.t('app.restoreWarn'), i18n.global.t('commons.button.recover'), {
confirmButtonText: i18n.global.t('commons.button.confirm'),
cancelButtonText: i18n.global.t('commons.button.cancel'),
}).then(async () => {
onRecover(row);
});
}
onRecover(row);
},
},
{

View File

@ -1577,8 +1577,6 @@ const message = {
upgradeHelper: 'The abnormal application needs to be synchronized to the normal state first',
installWarn:
'Currently, if the port external access is not checked, it will not be able to access through the external network IP: port. Do you want to continue?',
restoreWarn:
'The restore operation will delete the current data of the application and restart it. This operation cannot be rolled back, continue?',
showIgnore: 'View ignore application',
cancelIgnore: 'Cancel ignore',
ignoreList: 'ignore list',

View File

@ -1476,7 +1476,6 @@ const message = {
installHelper: '配置鏡像加速可以解決鏡像拉取失敗的問題',
upgradeHelper: '異常應用需要先同步到正常狀態',
installWarn: '當前未勾選端口外部訪問將無法通過外網IP:端口訪問是否繼續 ',
restoreWarn: '恢復操作將刪除該應用當前數據並重啟此操作不可回滾是否繼續?',
showIgnore: '查看忽略應用',
cancelIgnore: '取消忽略',
ignoreList: '忽略列表',

View File

@ -1476,7 +1476,6 @@ const message = {
installHelper: '配置镜像加速可以解决镜像拉取失败的问题',
upgradeHelper: '异常应用需要先同步到正常状态',
installWarn: '当前未勾选端口外部访问将无法通过外网IP:端口访问是否继续',
restoreWarn: '恢复操作将删除该应用当前数据并重启此操作不可回滚是否继续?',
showIgnore: '查看忽略应用',
cancelIgnore: '取消忽略',
ignoreList: '忽略列表',

View File

@ -304,9 +304,16 @@ const onDelete = async (row: Cronjob.CronjobInfo | null) => {
};
const onSubmitDelete = async () => {
await deleteCronjob({ ids: operateIDs.value, cleanData: cleanData.value });
MsgSuccess(i18n.global.t('commons.msg.deleteSuccess'));
search();
loading.value = true;
await deleteCronjob({ ids: operateIDs.value, cleanData: cleanData.value })
.then(() => {
loading.value = false;
MsgSuccess(i18n.global.t('commons.msg.deleteSuccess'));
search();
})
.catch(() => {
loading.value = false;
});
};
const onChangeStatus = async (id: number, status: string) => {