Browse Source

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

pull/3778/head
ssongliu 10 months ago committed by GitHub
parent
commit
c758c1ce87
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      backend/app/dto/cronjob.go
  2. 5
      backend/app/service/cornjob.go
  3. 3
      cmd/server/docs/docs.go
  4. 3
      cmd/server/docs/swagger.json
  5. 2
      cmd/server/docs/swagger.yaml
  6. 11
      frontend/src/components/upload/index.vue
  7. 2
      frontend/src/lang/modules/en.ts
  8. 1
      frontend/src/lang/modules/tw.ts
  9. 1
      frontend/src/lang/modules/zh.ts
  10. 13
      frontend/src/views/cronjob/index.vue

1
backend/app/dto/cronjob.go

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

5
backend/app/service/cornjob.go

@ -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 {

3
cmd/server/docs/docs.go

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

3
cmd/server/docs/swagger.json

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

2
cmd/server/docs/swagger.yaml

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

11
frontend/src/components/upload/index.vue

@ -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);
},
},
{

2
frontend/src/lang/modules/en.ts

@ -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',

1
frontend/src/lang/modules/tw.ts

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

1
frontend/src/lang/modules/zh.ts

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

13
frontend/src/views/cronjob/index.vue

@ -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…
Cancel
Save