mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-23 18:49:21 +08:00
fix: 解决计划任务记录删除时文件被误删问题 (#3777)
This commit is contained in:
parent
d82086ce4a
commit
c758c1ce87
@ -53,6 +53,7 @@ type CronjobDownload struct {
|
||||
}
|
||||
|
||||
type CronjobClean struct {
|
||||
IsDelete bool `json:"isDelete"`
|
||||
CleanData bool `json:"cleanData"`
|
||||
CronjobID uint `json:"cronjobID" validate:"required"`
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -14924,6 +14924,9 @@ const docTemplate = `{
|
||||
},
|
||||
"cronjobID": {
|
||||
"type": "integer"
|
||||
},
|
||||
"isDelete": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -14917,6 +14917,9 @@
|
||||
},
|
||||
"cronjobID": {
|
||||
"type": "integer"
|
||||
},
|
||||
"isDelete": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -573,6 +573,8 @@ definitions:
|
||||
type: boolean
|
||||
cronjobID:
|
||||
type: integer
|
||||
isDelete:
|
||||
type: boolean
|
||||
required:
|
||||
- cronjobID
|
||||
type: object
|
||||
|
@ -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);
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -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',
|
||||
|
@ -1476,7 +1476,6 @@ const message = {
|
||||
installHelper: '配置鏡像加速可以解決鏡像拉取失敗的問題',
|
||||
upgradeHelper: '異常應用需要先同步到正常狀態',
|
||||
installWarn: '當前未勾選端口外部訪問,將無法通過外網IP:端口訪問,是否繼續? ',
|
||||
restoreWarn: '恢復操作將刪除該應用當前數據並重啟。此操作不可回滾,是否繼續?',
|
||||
showIgnore: '查看忽略應用',
|
||||
cancelIgnore: '取消忽略',
|
||||
ignoreList: '忽略列表',
|
||||
|
@ -1476,7 +1476,6 @@ const message = {
|
||||
installHelper: '配置镜像加速可以解决镜像拉取失败的问题',
|
||||
upgradeHelper: '异常应用需要先同步到正常状态',
|
||||
installWarn: '当前未勾选端口外部访问,将无法通过外网IP:端口访问,是否继续?',
|
||||
restoreWarn: '恢复操作将删除该应用当前数据并重启。此操作不可回滚,是否继续?',
|
||||
showIgnore: '查看忽略应用',
|
||||
cancelIgnore: '取消忽略',
|
||||
ignoreList: '忽略列表',
|
||||
|
@ -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) => {
|
||||
|
Loading…
Reference in New Issue
Block a user