From 4d2f89ca8023063131a77ce39f04b5eb6763840a Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Fri, 1 Jul 2022 16:39:35 +0800 Subject: [PATCH] #2225 fix bug --- models/attachment.go | 2 +- models/repo_watch.go | 5 +++++ models/reward_periodic_task.go | 2 +- services/task/task.go | 13 +++++++++++-- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/models/attachment.go b/models/attachment.go index 3dc8eac49..e7051c632 100755 --- a/models/attachment.go +++ b/models/attachment.go @@ -667,7 +667,7 @@ func Attachments(opts *AttachmentsOptions) ([]*AttachmentInfo, int64, error) { func GetAllDatasetContributorByDatasetId(datasetId int64) ([]*User, error) { r := make([]*User, 0) - if err := x.Select("distinct(user.*)").Table("attachment").Join("LEFT", "user", "user.ID = attachment.uploader_id").Where("attachment.dataset_id = ?", datasetId).Find(&r); err != nil { + if err := x.Select("distinct(public.user.*)").Table("attachment").Join("LEFT", "user", "public.user.ID = attachment.uploader_id").Where("attachment.dataset_id = ?", datasetId).Find(&r); err != nil { return nil, err } return r, nil diff --git a/models/repo_watch.go b/models/repo_watch.go index 864aec254..485874301 100644 --- a/models/repo_watch.go +++ b/models/repo_watch.go @@ -204,6 +204,11 @@ func notifyWatchers(e Engine, actions ...*Action) error { // Send the act to task chan ActionChan4Task <- *act + // If it has nothing to do with repo, return directly + if act.Repo == nil && act.RepoID == 0 { + return nil + } + if repoChanged { act.loadRepo() repo = act.Repo diff --git a/models/reward_periodic_task.go b/models/reward_periodic_task.go index 910f4fe8e..5e5466e86 100644 --- a/models/reward_periodic_task.go +++ b/models/reward_periodic_task.go @@ -90,7 +90,7 @@ func GetPeriodicTaskBySourceIdAndType(sourceType SourceType, sourceId string, op r := RewardPeriodicTask{} _, err := x.SQL("select rpt.* from reward_periodic_task rpt "+ "inner join reward_operate_record ror on rpt.operate_serial_no = ror.serial_no"+ - " where ror.source_type = ? and source_id = ? and operate_type = ? ", sourceType.Name(), sourceId, operateType.Name()).Get(&r) + " where ror.source_type = ? and ror.source_id = ? and ror.operate_type = ? ", sourceType.Name(), sourceId, operateType.Name()).Get(&r) if err != nil { return nil, err } diff --git a/services/task/task.go b/services/task/task.go index 78f188997..5fc5e9bcb 100644 --- a/services/task/task.go +++ b/services/task/task.go @@ -9,13 +9,22 @@ import ( ) func Accomplish(action models.Action) { + defer func() { + if err := recover(); err != nil { + combinedErr := fmt.Errorf("%s\n%s", err, log.Stack(2)) + log.Error("PANIC:%v", combinedErr) + } + }() action.OpType = models.GetTaskOptType(action) switch action.OpType { - case models.ActionCreateRepo, - models.ActionCreateImage: + case models.ActionCreateRepo: if action.Repo.IsPrivate { return } + case models.ActionCreateImage: + if action.IsPrivate { + return + } case models.ActionBindWechat: n, err := models.CountWechatBindLog(action.Content, models.WECHAT_BIND) if err != nil {