fix: resolve linux electron backend fork ENOTDIR error

This commit is contained in:
ZacharyZcR
2026-05-13 16:27:31 +08:00
parent ec87f8a4d1
commit 69fbce9594
+4 -2
View File
@@ -566,7 +566,7 @@ function getBackendPaths() {
return { entryPath: path.join(backendDir, "starter.js"), backendCwd: backendDir }; return { entryPath: path.join(backendDir, "starter.js"), backendCwd: backendDir };
} }
// fork() does not go through Electron's asar redirector — use the unpacked path // fork() does not go through Electron's asar redirector — use the unpacked path
const unpackedRoot = appRoot.replace("app.asar", "app.asar.unpacked"); const unpackedRoot = appRoot.replace(/app\.asar(?!\.unpacked)/, "app.asar.unpacked");
const backendDir = path.join(unpackedRoot, "dist", "backend", "backend"); const backendDir = path.join(unpackedRoot, "dist", "backend", "backend");
return { entryPath: path.join(backendDir, "starter.js"), backendCwd: backendDir }; return { entryPath: path.join(backendDir, "starter.js"), backendCwd: backendDir };
} }
@@ -606,7 +606,9 @@ function startBackendServer() {
logToFile(" backendCwd exists:", fs.existsSync(backendCwd)); logToFile(" backendCwd exists:", fs.existsSync(backendCwd));
backendProcess = fork(entryPath, [], { backendProcess = fork(entryPath, [], {
cwd: backendCwd, cwd: fs.existsSync(backendCwd) && fs.statSync(backendCwd).isDirectory()
? backendCwd
: dataDir,
env: { env: {
...process.env, ...process.env,
DATA_DIR: dataDir, DATA_DIR: dataDir,