MCPcopy Create free account
hub / github.com/VirtualHotBar/NetMount / saveTask

Function saveTask

src/controller/task/task.ts:7–26  ·  view source on GitHub ↗
(taskInfo: TaskListItem)

Source from the content-addressed store, hash-verified

5const taskScheduler = new TaskScheduler()
6
7function saveTask(taskInfo: TaskListItem) {
8 const existingTaskIndex = nmConfig.task.findIndex(task => task.name === taskInfo.name)
9
10 if (existingTaskIndex !== -1) {
11 // 存在同名任务,更新已有任务
12 if (taskInfo.run.runId) {
13 taskScheduler.cancelTask(taskInfo.name)
14 }
15 nmConfig.task[existingTaskIndex] = taskInfo
16 } else {
17 // 不存在同名任务,直接添加新任务
18 nmConfig.task.push(taskInfo)
19 }
20 if (taskInfo.run.mode !== 'start') {
21 taskScheduler.addTask(taskInfo)
22 }
23
24 saveNmConfig()
25 return true
26}
27
28function delTask(taskName: string) {
29 taskScheduler.cancelTask(taskName)

Callers 1

AddTask_pageFunction · 0.90

Calls 3

saveNmConfigFunction · 0.90
cancelTaskMethod · 0.80
addTaskMethod · 0.80

Tested by

no test coverage detected