MCPcopy
hub / github.com/ChineseSubFinder/ChineseSubFinder / BeforeGetOneJob

Method BeforeGetOneJob

pkg/task_queue/get.go:10–37  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8)
9
10func (t *TaskQueue) BeforeGetOneJob() {
11 defer t.queueLock.Unlock()
12 t.queueLock.Lock()
13
14 // 这里需要手动判断 Done 的任务是否超过三个月了,超过就需要手动删除
15 for TaskPriority := 0; TaskPriority <= taskPriorityCount; TaskPriority++ {
16 t.taskPriorityMapList[TaskPriority].Each(func(key interface{}, value interface{}) {
17
18 nowOneJob := value.(task_queue2.OneJob)
19 if //nowOneJob.JobStatus == task_queue.Done &&
20 // 默认是 90day, A.After(B) : A > B == true
21 (time.Time)(nowOneJob.UpdateTime).AddDate(0, 0, settings.Get().AdvancedSettings.TaskQueue.ExpirationTime).After(time.Now()) == false {
22 // 找到就删除
23 bok, err := t.del(nowOneJob.Id)
24 if err != nil {
25 t.log.Errorf("GetOneWaitingJob.Del.Done ExpirationTime %v error: %s", settings.Get().AdvancedSettings.TaskQueue.ExpirationTime, err.Error())
26 return
27 }
28 if bok == false {
29 t.log.Errorf("GetOneWaitingJob.Del.Done ExpirationTime %v error: %s", settings.Get().AdvancedSettings.TaskQueue.ExpirationTime, "Del failed")
30 return
31
32 }
33 return
34 }
35 })
36 }
37}
38
39// GetOneJob 优先获取 GetOneWaitingJob 然后才是 GetOneDoneJob
40func (t *TaskQueue) GetOneJob() (bool, task_queue2.OneJob, error) {

Callers 1

queueDownloaderLocalMethod · 0.80

Calls 4

delMethod · 0.95
GetFunction · 0.92
UnlockMethod · 0.80
LockMethod · 0.80

Tested by

no test coverage detected