(mountId: string)
| 79 | }; |
| 80 | |
| 81 | export const createFileMount = async (mountId: string) => { |
| 82 | try { |
| 83 | const mount = await findMountById(mountId); |
| 84 | const baseFilePath = await getBaseFilesPath(mountId); |
| 85 | |
| 86 | const serverId = await getServerId(mount); |
| 87 | |
| 88 | if (serverId) { |
| 89 | const command = getCreateFileCommand( |
| 90 | baseFilePath, |
| 91 | mount.filePath || "", |
| 92 | mount.content || "", |
| 93 | ); |
| 94 | await execAsyncRemote(serverId, command); |
| 95 | } else { |
| 96 | await createFile(baseFilePath, mount.filePath || "", mount.content || ""); |
| 97 | } |
| 98 | } catch (error) { |
| 99 | console.log(`Error creating the file mount: ${error}`); |
| 100 | throw new TRPCError({ |
| 101 | code: "BAD_REQUEST", |
| 102 | message: `Error creating the mount ${error instanceof Error ? error.message : error}`, |
| 103 | cause: error, |
| 104 | }); |
| 105 | } |
| 106 | }; |
| 107 | |
| 108 | export const findMountById = async (mountId: string) => { |
| 109 | const mount = await db.query.mounts.findFirst({ |
no test coverage detected