diff --git a/backend/app/api/v1/cronjob.go b/backend/app/api/v1/cronjob.go index 0515c2a79..4b3945b77 100644 --- a/backend/app/api/v1/cronjob.go +++ b/backend/app/api/v1/cronjob.go @@ -101,11 +101,7 @@ func (b *BaseApi) LoadRecordLog(c *gin.Context) { if err := helper.CheckBindAndValidate(&req, c); err != nil { return } - content, err := cronjobService.LoadRecordLog(req) - if err != nil { - helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) - return - } + content := cronjobService.LoadRecordLog(req) helper.SuccessWithData(c, content) } diff --git a/backend/app/service/cornjob.go b/backend/app/service/cornjob.go index 57b9be2d3..c56dde735 100644 --- a/backend/app/service/cornjob.go +++ b/backend/app/service/cornjob.go @@ -11,7 +11,6 @@ import ( "github.com/1Panel-dev/1Panel/backend/app/dto" "github.com/1Panel-dev/1Panel/backend/app/model" - "github.com/1Panel-dev/1Panel/backend/buserr" "github.com/1Panel-dev/1Panel/backend/constant" "github.com/1Panel-dev/1Panel/backend/global" "github.com/jinzhu/copier" @@ -33,7 +32,7 @@ type ICronjobService interface { StartJob(cronjob *model.Cronjob) (string, error) CleanRecord(req dto.CronjobClean) error - LoadRecordLog(req dto.OperateByID) (string, error) + LoadRecordLog(req dto.OperateByID) string } func NewICronjobService() ICronjobService { @@ -77,19 +76,19 @@ func (u *CronjobService) SearchRecords(search dto.SearchRecord) (int64, interfac return total, dtoCronjobs, err } -func (u *CronjobService) LoadRecordLog(req dto.OperateByID) (string, error) { +func (u *CronjobService) LoadRecordLog(req dto.OperateByID) string { record, err := cronjobRepo.GetRecord(commonRepo.WithByID(req.ID)) if err != nil { - return "", err + return "" } if _, err := os.Stat(record.Records); err != nil { - return "", buserr.New("ErrHttpReqNotFound") + return "" } content, err := os.ReadFile(record.Records) if err != nil { - return "", err + return "" } - return string(content), nil + return string(content) } func (u *CronjobService) CleanRecord(req dto.CronjobClean) error { diff --git a/backend/app/service/cronjob_helper.go b/backend/app/service/cronjob_helper.go index 1822c05c9..892c6c036 100644 --- a/backend/app/service/cronjob_helper.go +++ b/backend/app/service/cronjob_helper.go @@ -82,7 +82,10 @@ func (u *CronjobService) HandleJob(cronjob *model.Cronjob) { } if err != nil { - cronjobRepo.EndRecords(record, constant.StatusFailed, err.Error(), string(message)) + if len(message) != 0 { + record.Records, _ = mkdirAndWriteFile(cronjob, record.StartTime, message) + } + cronjobRepo.EndRecords(record, constant.StatusFailed, err.Error(), record.Records) return } if len(message) != 0 { diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 36af3f917..6f9475743 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -806,7 +806,7 @@ const message = { database: 'Backup database', missBackupAccount: 'The backup account could not be found', syncDate: 'Synchronization time ', - releaseMemory: 'Free memory', + clean: 'Cache Clean', curl: 'Access URL', taskName: 'Cronjob name', cronSpec: 'Lifecycle', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index 2010bfcf2..907a75814 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -768,7 +768,7 @@ const message = { database: '備份數據庫', missBackupAccount: '未能找到備份賬號', syncDate: '同步時間 ', - releaseMemory: '釋放內存', + clean: '缓存清理', curl: '訪問 URL', taskName: '任務名稱', cronSpec: '執行周期', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index edb51acd5..fd39316b4 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -769,7 +769,7 @@ const message = { database: '备份数据库', missBackupAccount: '未能找到备份账号', syncDate: '同步时间 ', - releaseMemory: '释放内存', + clean: '缓存清理', curl: '访问 URL', taskName: '任务名称', cronSpec: '执行周期', diff --git a/frontend/src/views/cronjob/record/index.vue b/frontend/src/views/cronjob/record/index.vue index 598eaebeb..f8d73a682 100644 --- a/frontend/src/views/cronjob/record/index.vue +++ b/frontend/src/views/cronjob/record/index.vue @@ -405,10 +405,6 @@ const forDetail = async (row: Cronjob.Record) => { loadRecord(row); }; const loadRecord = async (row: Cronjob.Record) => { - if (row.status === 'Failed') { - currentRecordDetail.value = row.records; - return; - } if (row.records) { const res = await getRecordLog(row.id); currentRecordDetail.value = res.data;