chore: change path.join to path.posix.join
This commit is contained in:
parent
7aaa920815
commit
f38919d6cf
@ -22,13 +22,13 @@ export class SecureGitClient {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Create a temporary directory
|
// 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}`);
|
console.log(`Temporary directory created: ${tempDir}`);
|
||||||
|
|
||||||
// Write files to the temporary directory
|
// Write files to the temporary directory
|
||||||
console.log(`Writing ${fileData.length} files.`);
|
console.log(`Writing ${fileData.length} files.`);
|
||||||
for (const { id, data } of fileData) {
|
for (const { id, data } of fileData) {
|
||||||
const filePath = path.join(tempDir, id);
|
const filePath = path.posix.join(tempDir, id);
|
||||||
const dirPath = path.dirname(filePath);
|
const dirPath = path.dirname(filePath);
|
||||||
|
|
||||||
if (!fs.existsSync(dirPath)) {
|
if (!fs.existsSync(dirPath)) {
|
||||||
|
@ -172,7 +172,7 @@ io.on("connection", async (socket) => {
|
|||||||
// Change the owner of the project directory to user
|
// Change the owner of the project directory to user
|
||||||
const fixPermissions = async () => {
|
const fixPermissions = async () => {
|
||||||
await containers[data.sandboxId].commands.run(
|
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 containerFiles = containers[data.sandboxId].files;
|
||||||
const promises = sandboxFiles.fileData.map(async (file) => {
|
const promises = sandboxFiles.fileData.map(async (file) => {
|
||||||
try {
|
try {
|
||||||
const filePath = path.join(dirName, file.id);
|
const filePath = path.posix.join(dirName, file.id);
|
||||||
const parentDirectory = path.dirname(filePath);
|
const parentDirectory = path.dirname(filePath);
|
||||||
if (!containerFiles.exists(parentDirectory)) {
|
if (!containerFiles.exists(parentDirectory)) {
|
||||||
await containerFiles.makeDir(parentDirectory);
|
await containerFiles.makeDir(parentDirectory);
|
||||||
@ -245,7 +245,7 @@ io.on("connection", async (socket) => {
|
|||||||
file.data = body;
|
file.data = body;
|
||||||
|
|
||||||
await containers[data.sandboxId].files.write(
|
await containers[data.sandboxId].files.write(
|
||||||
path.join(dirName, file.id),
|
path.posix.join(dirName, file.id),
|
||||||
body
|
body
|
||||||
);
|
);
|
||||||
fixPermissions();
|
fixPermissions();
|
||||||
@ -267,8 +267,8 @@ io.on("connection", async (socket) => {
|
|||||||
|
|
||||||
await moveFile(
|
await moveFile(
|
||||||
containers[data.sandboxId].files,
|
containers[data.sandboxId].files,
|
||||||
path.join(dirName, fileId),
|
path.posix.join(dirName, fileId),
|
||||||
path.join(dirName, newFileId)
|
path.posix.join(dirName, newFileId)
|
||||||
);
|
);
|
||||||
fixPermissions();
|
fixPermissions();
|
||||||
|
|
||||||
@ -360,7 +360,7 @@ io.on("connection", async (socket) => {
|
|||||||
const id = `projects/${data.sandboxId}/${name}`;
|
const id = `projects/${data.sandboxId}/${name}`;
|
||||||
|
|
||||||
await containers[data.sandboxId].files.write(
|
await containers[data.sandboxId].files.write(
|
||||||
path.join(dirName, id),
|
path.posix.join(dirName, id),
|
||||||
""
|
""
|
||||||
);
|
);
|
||||||
fixPermissions();
|
fixPermissions();
|
||||||
@ -397,7 +397,7 @@ io.on("connection", async (socket) => {
|
|||||||
const id = `projects/${data.sandboxId}/${name}`;
|
const id = `projects/${data.sandboxId}/${name}`;
|
||||||
|
|
||||||
await containers[data.sandboxId].files.makeDir(
|
await containers[data.sandboxId].files.makeDir(
|
||||||
path.join(dirName, id)
|
path.posix.join(dirName, id)
|
||||||
);
|
);
|
||||||
|
|
||||||
callback();
|
callback();
|
||||||
@ -426,8 +426,8 @@ io.on("connection", async (socket) => {
|
|||||||
|
|
||||||
await moveFile(
|
await moveFile(
|
||||||
containers[data.sandboxId].files,
|
containers[data.sandboxId].files,
|
||||||
path.join(dirName, fileId),
|
path.posix.join(dirName, fileId),
|
||||||
path.join(dirName, newFileId)
|
path.posix.join(dirName, newFileId)
|
||||||
);
|
);
|
||||||
fixPermissions();
|
fixPermissions();
|
||||||
await renameFile(fileId, newFileId, file.data);
|
await renameFile(fileId, newFileId, file.data);
|
||||||
@ -449,7 +449,7 @@ io.on("connection", async (socket) => {
|
|||||||
if (!file) return;
|
if (!file) return;
|
||||||
|
|
||||||
await containers[data.sandboxId].files.remove(
|
await containers[data.sandboxId].files.remove(
|
||||||
path.join(dirName, fileId)
|
path.posix.join(dirName, fileId)
|
||||||
);
|
);
|
||||||
sandboxFiles.fileData = sandboxFiles.fileData.filter(
|
sandboxFiles.fileData = sandboxFiles.fileData.filter(
|
||||||
(f) => f.id !== fileId
|
(f) => f.id !== fileId
|
||||||
@ -476,7 +476,7 @@ io.on("connection", async (socket) => {
|
|||||||
await Promise.all(
|
await Promise.all(
|
||||||
files.map(async (file) => {
|
files.map(async (file) => {
|
||||||
await containers[data.sandboxId].files.remove(
|
await containers[data.sandboxId].files.remove(
|
||||||
path.join(dirName, file)
|
path.posix.join(dirName, file)
|
||||||
);
|
);
|
||||||
|
|
||||||
sandboxFiles.fileData = sandboxFiles.fileData.filter(
|
sandboxFiles.fileData = sandboxFiles.fileData.filter(
|
||||||
@ -532,7 +532,7 @@ io.on("connection", async (socket) => {
|
|||||||
//onExit: () => console.log("Terminal exited", id),
|
//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 = [
|
const defaultCommands = [
|
||||||
`cd "${defaultDirectory}"`,
|
`cd "${defaultDirectory}"`,
|
||||||
"export PS1='user> '",
|
"export PS1='user> '",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user