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

Function executeTask

src/controller/task/runner.ts:8–130  ·  view source on GitHub ↗
(task: TaskListItem)

Source from the content-addressed store, hash-verified

6 let taskMsg: string = task.runInfo.msg || ''
7
8 const executeTask = async (task: TaskListItem) => {
9 console.log(`Executing ${task.taskType} task: ${task.name}`)
10
11 const srcIsDir = task.source.path.endsWith('/')
12 const targetIsDir = task.target.path.endsWith('/')
13
14 /* if (item.isMove) {
15 if (item.isDir) {
16 moveDir(item.storageName, item.path, storageName!, path!);
17 } else {
18 moveFile(item.storageName, item.path, storageName!, path!);
19 }
20 } else {
21 if (item.isDir) {
22 copyDir(item.storageName, item.path, storageName!, path!);
23 } else {
24 copyFile(item.storageName, item.path, storageName!, path!)
25 }
26 } */
27
28 switch (task.taskType) {
29 case 'copy': {
30 //复制
31 if (srcIsDir && targetIsDir) {
32 //复制目录
33 await copyDir(
34 task.source.storageName,
35 task.source.path,
36 task.target.storageName,
37 task.target.path
38 )
39 } else if (!srcIsDir && !targetIsDir) {
40 //复制文件
41 await copyFile(
42 task.source.storageName,
43 task.source.path,
44 task.target.storageName,
45 task.target.path,
46 true
47 )
48 } else if (!srcIsDir && targetIsDir) {
49 //复制文件到目录
50 await copyFile(
51 task.source.storageName,
52 task.source.path,
53 task.target.storageName,
54 task.target.path
55 )
56 } else {
57 throw new Error('The directory cannot be copied/moved to a file')
58 }
59 break
60 }
61 case 'move': {
62 //移动
63 if (srcIsDir && targetIsDir) {
64 //移动目录
65 await moveDir(

Callers 1

runTaskFunction · 0.85

Calls 7

copyDirFunction · 0.90
copyFileFunction · 0.90
moveDirFunction · 0.90
moveFileFunction · 0.90
delDirFunction · 0.90
delFileFunction · 0.90
syncFunction · 0.90

Tested by

no test coverage detected