MCPcopy
hub / github.com/ChineseSubFinder/ChineseSubFinder / del

Method del

pkg/task_queue/task_queue.go:260–300  ·  view source on GitHub ↗
(jobId string)

Source from the content-addressed store, hash-verified

258}
259
260func (t *TaskQueue) del(jobId string) (bool, error) {
261 if t.isExist(jobId) == false {
262 return false, nil
263 }
264
265 taskPriority, bok := t.taskKeyMap.Get(jobId)
266 if bok == false {
267 return false, nil
268 }
269 // 删除连续剧的 tree.Map 里面的 tree.Set 的元素
270 needDelJobObj, bok := t.taskPriorityMapList[taskPriority.(int)].Get(jobId)
271 if bok == false {
272 return false, nil
273 }
274 needDelJob := needDelJobObj.(task_queue2.OneJob)
275 jobSetsObj, bok := t.taskGroupBySeries.Get(needDelJob.SeriesRootDirPath)
276 if bok == false {
277 return false, nil
278 }
279 jobSets := jobSetsObj.(*treeset.Set)
280 jobSets.Remove(jobId)
281 // 删除任务
282 t.taskKeyMap.Remove(jobId)
283 t.taskPriorityMapList[taskPriority.(int)].Remove(jobId)
284
285 err := t.save(taskPriority.(int))
286 if err != nil {
287 return false, err
288 }
289 // 删除任务的时候也需要删除对应的日志
290 pathRoot := filepath.Join(pkg.ConfigRootDirFPath(), "Logs")
291 fileFPath := filepath.Join(pathRoot, common.OnceLogPrefix+jobId+".log")
292 if pkg.IsFile(fileFPath) == true {
293 err = os.Remove(fileFPath)
294 if err != nil {
295 t.log.Errorln("del job", jobId, "logfile,error:", err)
296 }
297 }
298
299 return true, nil
300}
301
302// Del 删除一个元素
303func (t *TaskQueue) Del(jobId string) (bool, error) {

Callers 2

DelMethod · 0.95
BeforeGetOneJobMethod · 0.95

Calls 5

isExistMethod · 0.95
saveMethod · 0.95
ConfigRootDirFPathFunction · 0.92
IsFileFunction · 0.92
GetMethod · 0.65

Tested by

no test coverage detected