#1928 解决数据集解压重复发送消息的问题

Merged
lewis merged 3 commits from zouap into V20220415 2 years ago
  1. +1
    -0
      modules/labelmsg/redismsgsender.go
  2. +16
    -10
      routers/repo/attachment.go

+ 1
- 0
modules/labelmsg/redismsgsender.go View File

@@ -50,6 +50,7 @@ func SendDecompressAttachToLabelOBS(attach string) error {
_, err := redisclient.Do("Publish", setting.DecompressOBSTaskName, attach)
if err != nil {
log.Critical("redis Publish failed.")
return err
}

log.Info("LabelDecompressOBSQueue(%s) success", attach)


+ 16
- 10
routers/repo/attachment.go View File

@@ -78,7 +78,7 @@ func UploadAttachmentUI(ctx *context.Context) {
}

func EditAttachmentUI(ctx *context.Context) {
id, _ := strconv.ParseInt(ctx.Params(":id"), 10, 64)
ctx.Data["PageIsDataset"] = true
attachment, _ := models.GetAttachmentByID(id)
@@ -986,23 +986,29 @@ func HandleUnDecompressAttachment() {
if attach.Type == models.TypeCloudBrainOne {
err = worker.SendDecompressTask(contexExt.Background(), attach.UUID, attach.Name)
if err != nil {
log.Error("SendDecompressTask(%s) failed:%s", attach.UUID, err.Error())
log.Error("SendDecompressTask(%s) failed:%s", attach.UUID, err.Error())
} else {
attach.DecompressState = models.DecompressStateIng
err = models.UpdateAttachment(attach)
if err != nil {
log.Error("UpdateAttachment state(%s) failed:%s", attach.UUID, err.Error())
}
updateAttachmentDecompressStateIng(attach)
}
} else if attach.Type == models.TypeCloudBrainTwo {
attachjson, _ := json.Marshal(attach)
labelmsg.SendDecompressAttachToLabelOBS(string(attachjson))
err = labelmsg.SendDecompressAttachToLabelOBS(string(attachjson))
if err != nil {
log.Error("SendDecompressTask to labelsystem (%s) failed:%s", attach.UUID, err.Error())
} else {
updateAttachmentDecompressStateIng(attach)
}
}

}

return
}
func updateAttachmentDecompressStateIng(attach *models.Attachment) {
attach.DecompressState = models.DecompressStateIng
err := models.UpdateAttachment(attach)
if err != nil {
log.Error("UpdateAttachment state(%s) failed:%s", attach.UUID, err.Error())
}
}

func QueryAllPublicDataset(ctx *context.Context) {
attachs, err := models.GetAllPublicAttachments()


Loading…
Cancel
Save