fix: catch errors when copying files to the container

This commit is contained in:
James Murdza 2024-09-06 18:13:42 -07:00
parent 8921cd83bb
commit 4ebd6dea96

View File

@ -177,7 +177,7 @@ io.on("connection", async (socket) => {
}; };
const sandboxFiles = await getSandboxFiles(data.sandboxId); const sandboxFiles = await getSandboxFiles(data.sandboxId);
sandboxFiles.fileData.forEach(async (file) => { const promises = sandboxFiles.fileData.map(async (file) => {
const filePath = path.join(dirName, file.id); const filePath = path.join(dirName, file.id);
try { try {
await containers[data.sandboxId].files.makeDir( await containers[data.sandboxId].files.makeDir(
@ -188,6 +188,8 @@ io.on("connection", async (socket) => {
} }
await containers[data.sandboxId].files.write(filePath, file.data); await containers[data.sandboxId].files.write(filePath, file.data);
}); });
await Promise.all(promises);
fixPermissions(); fixPermissions();
socket.emit("loaded", sandboxFiles.files); socket.emit("loaded", sandboxFiles.files);