worker use md5

This commit is contained in:
Samuel Lorch 2024-05-11 00:43:58 +02:00
parent 981b745c9e
commit c7df166a2d
2 changed files with 45 additions and 10 deletions

View file

@ -18,9 +18,10 @@ func StartTask(conf config.Config, data types.TaskStart) error {
defer taskMutex.Unlock()
tasks[data.ID] = &types.Task{
ID: data.ID,
Type: data.Type,
FileID: data.FileID,
ID: data.ID,
Type: data.Type,
FileID: data.FileID,
FileMD5: data.FileMD5,
}
switch data.Type {
@ -34,9 +35,14 @@ func StartTask(conf config.Config, data types.TaskStart) error {
tasks[data.ID].Status = constants.TASK_STATUS_RUNNING
go func() {
defer func() {
if tasks[data.ID].Status == constants.TASK_STATUS_RUNNING {
tasks[data.ID].Status = constants.TASK_STATUS_FAILED
tasks[data.ID].Log = append(tasks[data.ID].Log, "Task Status Set to Failed by defer")
taskMutex.Lock()
defer taskMutex.Unlock()
t, ok := tasks[data.ID]
if ok {
if t.Status == constants.TASK_STATUS_RUNNING {
t.Status = constants.TASK_STATUS_FAILED
t.Log = append(t.Log, "Task Status Set to Failed by defer")
}
}
}()
RunHealthCheck(conf, tasks[data.ID], hData)