(options: {
fileId: string
fileName: string
fromPath: string
pageId: string
messageId: string
})
| 117 | } |
| 118 | |
| 119 | export async function moveAttachmentFile(options: { |
| 120 | fileId: string |
| 121 | fileName: string |
| 122 | fromPath: string |
| 123 | pageId: string |
| 124 | messageId: string |
| 125 | }): Promise<string> { |
| 126 | const sourcePath = await resolveAttachmentPath(options.fromPath) |
| 127 | if (!(await pathExists(sourcePath))) { |
| 128 | throw new Error(`Attachment source not found: ${options.fromPath}`) |
| 129 | } |
| 130 | |
| 131 | const relativePath = buildStoredRelativePath( |
| 132 | options.fileId, |
| 133 | options.fileName, |
| 134 | options.pageId, |
| 135 | options.messageId |
| 136 | ) |
| 137 | const targetPath = await resolveAttachmentPath(relativePath) |
| 138 | |
| 139 | await mkdir(path.dirname(targetPath), { recursive: true }) |
| 140 | await moveFile(sourcePath, targetPath) |
| 141 | |
| 142 | return relativePath |
| 143 | } |
| 144 | |
| 145 | export async function cleanupMessageAttachmentFiles( |
| 146 | pageId: string, |
no test coverage detected