mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-24 02:59:16 +08:00
fix: 解决计划任务记录删除时文件被误删问题 (#3777)
This commit is contained in:
parent
d82086ce4a
commit
c758c1ce87
@ -53,6 +53,7 @@ type CronjobDownload struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CronjobClean struct {
|
type CronjobClean struct {
|
||||||
|
IsDelete bool `json:"isDelete"`
|
||||||
CleanData bool `json:"cleanData"`
|
CleanData bool `json:"cleanData"`
|
||||||
CronjobID uint `json:"cronjobID" validate:"required"`
|
CronjobID uint `json:"cronjobID" validate:"required"`
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,8 @@ func (u *CronjobService) CleanRecord(req dto.CronjobClean) error {
|
|||||||
} else {
|
} else {
|
||||||
u.removeExpiredLog(cronjob)
|
u.removeExpiredLog(cronjob)
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
if req.IsDelete {
|
||||||
records, _ := backupRepo.ListRecord(backupRepo.WithByCronID(cronjob.ID))
|
records, _ := backupRepo.ListRecord(backupRepo.WithByCronID(cronjob.ID))
|
||||||
for _, records := range records {
|
for _, records := range records {
|
||||||
records.CronjobID = 0
|
records.CronjobID = 0
|
||||||
@ -224,7 +225,7 @@ func (u *CronjobService) Delete(req dto.CronjobBatchDelete) error {
|
|||||||
global.Cron.Remove(cron.EntryID(idItem))
|
global.Cron.Remove(cron.EntryID(idItem))
|
||||||
}
|
}
|
||||||
global.LOG.Infof("stop cronjob entryID: %s", cronjob.EntryIDs)
|
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
|
return err
|
||||||
}
|
}
|
||||||
if err := cronjobRepo.Delete(commonRepo.WithByID(id)); err != nil {
|
if err := cronjobRepo.Delete(commonRepo.WithByID(id)); err != nil {
|
||||||
|
@ -14924,6 +14924,9 @@ const docTemplate = `{
|
|||||||
},
|
},
|
||||||
"cronjobID": {
|
"cronjobID": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"isDelete": {
|
||||||
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -14917,6 +14917,9 @@
|
|||||||
},
|
},
|
||||||
"cronjobID": {
|
"cronjobID": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"isDelete": {
|
||||||
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -573,6 +573,8 @@ definitions:
|
|||||||
type: boolean
|
type: boolean
|
||||||
cronjobID:
|
cronjobID:
|
||||||
type: integer
|
type: integer
|
||||||
|
isDelete:
|
||||||
|
type: boolean
|
||||||
required:
|
required:
|
||||||
- cronjobID
|
- cronjobID
|
||||||
type: object
|
type: object
|
||||||
|
@ -322,16 +322,7 @@ const buttons = [
|
|||||||
{
|
{
|
||||||
label: i18n.global.t('commons.button.recover'),
|
label: i18n.global.t('commons.button.recover'),
|
||||||
click: (row: File.File) => {
|
click: (row: File.File) => {
|
||||||
if (type.value !== 'app') {
|
onRecover(row);
|
||||||
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);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1577,8 +1577,6 @@ const message = {
|
|||||||
upgradeHelper: 'The abnormal application needs to be synchronized to the normal state first',
|
upgradeHelper: 'The abnormal application needs to be synchronized to the normal state first',
|
||||||
installWarn:
|
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?',
|
'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',
|
showIgnore: 'View ignore application',
|
||||||
cancelIgnore: 'Cancel ignore',
|
cancelIgnore: 'Cancel ignore',
|
||||||
ignoreList: 'ignore list',
|
ignoreList: 'ignore list',
|
||||||
|
@ -1476,7 +1476,6 @@ const message = {
|
|||||||
installHelper: '配置鏡像加速可以解決鏡像拉取失敗的問題',
|
installHelper: '配置鏡像加速可以解決鏡像拉取失敗的問題',
|
||||||
upgradeHelper: '異常應用需要先同步到正常狀態',
|
upgradeHelper: '異常應用需要先同步到正常狀態',
|
||||||
installWarn: '當前未勾選端口外部訪問,將無法通過外網IP:端口訪問,是否繼續? ',
|
installWarn: '當前未勾選端口外部訪問,將無法通過外網IP:端口訪問,是否繼續? ',
|
||||||
restoreWarn: '恢復操作將刪除該應用當前數據並重啟。此操作不可回滾,是否繼續?',
|
|
||||||
showIgnore: '查看忽略應用',
|
showIgnore: '查看忽略應用',
|
||||||
cancelIgnore: '取消忽略',
|
cancelIgnore: '取消忽略',
|
||||||
ignoreList: '忽略列表',
|
ignoreList: '忽略列表',
|
||||||
|
@ -1476,7 +1476,6 @@ const message = {
|
|||||||
installHelper: '配置镜像加速可以解决镜像拉取失败的问题',
|
installHelper: '配置镜像加速可以解决镜像拉取失败的问题',
|
||||||
upgradeHelper: '异常应用需要先同步到正常状态',
|
upgradeHelper: '异常应用需要先同步到正常状态',
|
||||||
installWarn: '当前未勾选端口外部访问,将无法通过外网IP:端口访问,是否继续?',
|
installWarn: '当前未勾选端口外部访问,将无法通过外网IP:端口访问,是否继续?',
|
||||||
restoreWarn: '恢复操作将删除该应用当前数据并重启。此操作不可回滚,是否继续?',
|
|
||||||
showIgnore: '查看忽略应用',
|
showIgnore: '查看忽略应用',
|
||||||
cancelIgnore: '取消忽略',
|
cancelIgnore: '取消忽略',
|
||||||
ignoreList: '忽略列表',
|
ignoreList: '忽略列表',
|
||||||
|
@ -304,9 +304,16 @@ const onDelete = async (row: Cronjob.CronjobInfo | null) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onSubmitDelete = async () => {
|
const onSubmitDelete = async () => {
|
||||||
await deleteCronjob({ ids: operateIDs.value, cleanData: cleanData.value });
|
loading.value = true;
|
||||||
MsgSuccess(i18n.global.t('commons.msg.deleteSuccess'));
|
await deleteCronjob({ ids: operateIDs.value, cleanData: cleanData.value })
|
||||||
search();
|
.then(() => {
|
||||||
|
loading.value = false;
|
||||||
|
MsgSuccess(i18n.global.t('commons.msg.deleteSuccess'));
|
||||||
|
search();
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
loading.value = false;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const onChangeStatus = async (id: number, status: string) => {
|
const onChangeStatus = async (id: number, status: string) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user