From 023b3bdc5e273eb0b70d0d90cdaa57edd71dc18b Mon Sep 17 00:00:00 2001 From: James Murdza Date: Mon, 30 Sep 2024 04:20:14 -0700 Subject: [PATCH] fix: add missing await keywords --- backend/server/src/index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/server/src/index.ts b/backend/server/src/index.ts index c4ee2e0..c58aea4 100644 --- a/backend/server/src/index.ts +++ b/backend/server/src/index.ts @@ -239,9 +239,9 @@ io.on("connection", async (socket) => { } // Start filesystem watcher for the project directory - const watchDirectory = (directory: string) => { + const watchDirectory = async (directory: string) => { try { - containerFiles.watch(directory, async (event: FilesystemEvent) => { + await containerFiles.watch(directory, async (event: FilesystemEvent) => { try { function removeDirName(path : string, dirName : string) { @@ -340,17 +340,17 @@ io.on("connection", async (socket) => { }; // Watch the project directory - watchDirectory(projectDirectory); + await watchDirectory(projectDirectory); // Watch all subdirectories of the project directory, but not deeper // This also means directories created after the container is created won't be watched const dirContent = await containerFiles.list(projectDirectory); - dirContent.forEach((item : EntryInfo) => { + await Promise.all(dirContent.map(async (item : EntryInfo) => { if (item.type === "dir") { console.log("Watching " + item.path); - watchDirectory(item.path); + await watchDirectory(item.path); } - }) + })) socket.emit("loaded", sandboxFiles.files);