MCPcopy Create free account
hub / github.com/experdot/pointer / moveAttachment

Method moveAttachment

src/main/attachmentHandler.ts:113–140  ·  view source on GitHub ↗

* 移动附件(从temp到正式目录) * @param fileId 文件ID * @param fileName 文件名 * @param fromPath 源路径(相对路径) * @param pageId 目标页面ID * @param messageId 目标消息ID

(
    fileId: string,
    fileName: string,
    fromPath: string,
    pageId: string,
    messageId: string
  )

Source from the content-addressed store, hash-verified

111 * @param messageId 目标消息ID
112 */
113 async moveAttachment(
114 fileId: string,
115 fileName: string,
116 fromPath: string,
117 pageId: string,
118 messageId: string
119 ): Promise<{ success: boolean; localPath?: string; error?: string }> {
120 try {
121 const sourcePath = path.join(this.attachmentsDir, fromPath)
122
123 const targetDir = path.join(this.attachmentsDir, pageId, messageId)
124 await mkdir(targetDir, { recursive: true })
125
126 const ext = path.extname(fileName)
127 const targetPath = path.join(targetDir, `${fileId}${ext}`)
128
129 await rename(sourcePath, targetPath)
130
131 const relativePath = path.relative(this.attachmentsDir, targetPath)
132 return { success: true, localPath: relativePath }
133 } catch (error) {
134 console.error('移动附件失败:', error)
135 return {
136 success: false,
137 error: error instanceof Error ? error.message : '移动附件失败'
138 }
139 }
140 }
141
142 /**
143 * 清理指定消息的所有附件

Callers 1

setupAttachmentHandlersFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected