Skip to content

Commit

Permalink
Merge pull request #187 from kounoike:fix/delete-timing
Browse files Browse the repository at this point in the history
DeleteOriginalの削除タイミングを変更
  • Loading branch information
kounoike authored May 2, 2023
2 parents d7841dc + 17b22a7 commit 0306228
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions dtv/check_completed_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,21 @@ func (dtv *DTVUsecase) onProgramExtractedSubtitle(ctx context.Context, taskInfo
return nil
}

func (dtv *DTVUsecase) onProgramDeletedOriginal(ctx context.Context, taskInfo *asynq.TaskInfo) error {
var payload tasks.ProgramDeleteOriginalPayload
err := json.Unmarshal(taskInfo.Payload, &payload)
if err != nil {
dtv.logger.Warn("task payload json.Unmarshal error", zap.Error(err))
return err
}

for _, taskInfo := range payload.MonitorTaskInfos {
dtv.inspector.DeleteTask(taskInfo.Queue, taskInfo.ID)
}

return nil
}

func (dtv *DTVUsecase) CheckCompletedTask(ctx context.Context) error {
if dtv.inspector == nil {
return nil
Expand All @@ -260,9 +275,8 @@ func (dtv *DTVUsecase) CheckCompletedTask(ctx context.Context) error {
case tasks.TypeProgramExtractSubtitle:
_ = dtv.onProgramExtractedSubtitle(ctx, taskInfo)
case tasks.TypeProgramDeleteOriginal:
// 特に何もしない
_ = dtv.onProgramDeletedOriginal(ctx, taskInfo)
}
dtv.inspector.DeleteTask(queue, taskInfo.ID)
}
}
return nil
Expand Down

0 comments on commit 0306228

Please sign in to comment.