From 0f7eb9a8567aea086866db401514baccbc8d87b1 Mon Sep 17 00:00:00 2001 From: Akhileshrangani4 Date: Mon, 16 Sep 2024 16:28:58 -0400 Subject: [PATCH] chore: change path.join to path.posix.join --- backend/server/src/SecureGitClient.ts | 4 ++-- backend/server/src/index.ts | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/backend/server/src/SecureGitClient.ts b/backend/server/src/SecureGitClient.ts index 1ce5900..6fabce6 100644 --- a/backend/server/src/SecureGitClient.ts +++ b/backend/server/src/SecureGitClient.ts @@ -22,13 +22,13 @@ export class SecureGitClient { try { // Create a temporary directory - tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'git-push-')); + tempDir = fs.mkdtempSync(path.posix.join(os.tmpdir(), 'git-push-')); console.log(`Temporary directory created: ${tempDir}`); // Write files to the temporary directory console.log(`Writing ${fileData.length} files.`); for (const { id, data } of fileData) { - const filePath = path.join(tempDir, id); + const filePath = path.posix.join(tempDir, id); const dirPath = path.dirname(filePath); if (!fs.existsSync(dirPath)) { diff --git a/backend/server/src/index.ts b/backend/server/src/index.ts index f66553c..6106faa 100644 --- a/backend/server/src/index.ts +++ b/backend/server/src/index.ts @@ -172,7 +172,7 @@ io.on("connection", async (socket) => { // Change the owner of the project directory to user const fixPermissions = async () => { await containers[data.sandboxId].commands.run( - `sudo chown -R user "${path.join(dirName, "projects", data.sandboxId)}"` + `sudo chown -R user "${path.posix.join(dirName, "projects", data.sandboxId)}"` ); }; @@ -181,7 +181,7 @@ io.on("connection", async (socket) => { const containerFiles = containers[data.sandboxId].files; const promises = sandboxFiles.fileData.map(async (file) => { try { - const filePath = path.join(dirName, file.id); + const filePath = path.posix.join(dirName, file.id); const parentDirectory = path.dirname(filePath); if (!containerFiles.exists(parentDirectory)) { await containerFiles.makeDir(parentDirectory); @@ -245,7 +245,7 @@ io.on("connection", async (socket) => { file.data = body; await containers[data.sandboxId].files.write( - path.join(dirName, file.id), + path.posix.join(dirName, file.id), body ); fixPermissions(); @@ -267,8 +267,8 @@ io.on("connection", async (socket) => { await moveFile( containers[data.sandboxId].files, - path.join(dirName, fileId), - path.join(dirName, newFileId) + path.posix.join(dirName, fileId), + path.posix.join(dirName, newFileId) ); fixPermissions(); @@ -360,7 +360,7 @@ io.on("connection", async (socket) => { const id = `projects/${data.sandboxId}/${name}`; await containers[data.sandboxId].files.write( - path.join(dirName, id), + path.posix.join(dirName, id), "" ); fixPermissions(); @@ -397,7 +397,7 @@ io.on("connection", async (socket) => { const id = `projects/${data.sandboxId}/${name}`; await containers[data.sandboxId].files.makeDir( - path.join(dirName, id) + path.posix.join(dirName, id) ); callback(); @@ -426,8 +426,8 @@ io.on("connection", async (socket) => { await moveFile( containers[data.sandboxId].files, - path.join(dirName, fileId), - path.join(dirName, newFileId) + path.posix.join(dirName, fileId), + path.posix.join(dirName, newFileId) ); fixPermissions(); await renameFile(fileId, newFileId, file.data); @@ -449,7 +449,7 @@ io.on("connection", async (socket) => { if (!file) return; await containers[data.sandboxId].files.remove( - path.join(dirName, fileId) + path.posix.join(dirName, fileId) ); sandboxFiles.fileData = sandboxFiles.fileData.filter( (f) => f.id !== fileId @@ -476,7 +476,7 @@ io.on("connection", async (socket) => { await Promise.all( files.map(async (file) => { await containers[data.sandboxId].files.remove( - path.join(dirName, file) + path.posix.join(dirName, file) ); sandboxFiles.fileData = sandboxFiles.fileData.filter( @@ -532,7 +532,7 @@ io.on("connection", async (socket) => { //onExit: () => console.log("Terminal exited", id), }); - const defaultDirectory = path.join(dirName, "projects", data.sandboxId); + const defaultDirectory = path.posix.join(dirName, "projects", data.sandboxId); const defaultCommands = [ `cd "${defaultDirectory}"`, "export PS1='user> '",