From 4ebd6dea96b3c28a2b545009858e1c547e92538d Mon Sep 17 00:00:00 2001 From: James Murdza Date: Fri, 6 Sep 2024 18:13:42 -0700 Subject: [PATCH] fix: catch errors when copying files to the container --- backend/server/src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/server/src/index.ts b/backend/server/src/index.ts index c78272b..fe0690f 100644 --- a/backend/server/src/index.ts +++ b/backend/server/src/index.ts @@ -177,7 +177,7 @@ io.on("connection", async (socket) => { }; 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); try { 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 Promise.all(promises); + fixPermissions(); socket.emit("loaded", sandboxFiles.files);