mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 06:18:42 +02:00
BUGFIX: Electron app does not run on Linux due to incompatible glibc version and wrong usage of net.fetch (#2114)
This commit is contained in:
@@ -28,7 +28,7 @@ const debounce = require("lodash/debounce");
|
||||
const Store = require("electron-store");
|
||||
const store = new Store();
|
||||
const path = require("path");
|
||||
const { realpathSync } = require("fs");
|
||||
const { realpathSync, readFileSync } = require("fs");
|
||||
const { fileURLToPath } = require("url");
|
||||
|
||||
log.transports.file.level = store.get("file-log-level", "info");
|
||||
@@ -188,8 +188,8 @@ app.on("ready", async () => {
|
||||
let relativePath;
|
||||
/**
|
||||
* "realpathSync" will throw an error if "filePath" points to a non-existent file. If an error is thrown here, the
|
||||
* electron app will crash immediately. We can use fs.existsSync to check "filePath" before using it, but it's best
|
||||
* to try-catch the entire code block and avoid unexpected issues.
|
||||
* Electron app will not write any error logs, and the request will fail silently. We can use fs.existsSync to check
|
||||
* "filePath" before using it, but it's best to try-catch the entire code block.
|
||||
*/
|
||||
try {
|
||||
filePath = fileURLToPath(url);
|
||||
@@ -197,13 +197,7 @@ app.on("ready", async () => {
|
||||
relativePath = path.relative(__dirname, realPath);
|
||||
// Only allow access to files in "dist" folder or html files in the same directory
|
||||
if (method === "GET" && (relativePath.startsWith("dist") || relativePath.match(/^[a-zA-Z-_]*\.html/))) {
|
||||
/**
|
||||
* By default, requests made by net.fetch go through custom protocol handlers, so we have to explicitly tell it
|
||||
* to bypass those handles; otherwise, it creates an infinite loop.
|
||||
*
|
||||
* Ref: https://github.com/electron/electron/issues/39402
|
||||
*/
|
||||
return net.fetch(realPath, { bypassCustomProtocolHandlers: true });
|
||||
return new Response(readFileSync(realPath));
|
||||
}
|
||||
} catch (error) {
|
||||
log.error(error);
|
||||
|
||||
8
electron/package-lock.json
generated
8
electron/package-lock.json
generated
@@ -8,16 +8,16 @@
|
||||
"name": "bitburner",
|
||||
"version": "3.0.0",
|
||||
"dependencies": {
|
||||
"@catloversg/steamworks.js": "0.0.1",
|
||||
"@catloversg/steamworks.js": "0.0.2",
|
||||
"electron-log": "^4.4.8",
|
||||
"electron-store": "^8.1.0",
|
||||
"lodash": "^4.17.21"
|
||||
}
|
||||
},
|
||||
"node_modules/@catloversg/steamworks.js": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@catloversg/steamworks.js/-/steamworks.js-0.0.1.tgz",
|
||||
"integrity": "sha512-Kj3JZUVqYuLsF34g/N/Ap/aWsJHJoWKbvn/R19fzlZTJY+XMv5myRcngUuydwzvJzHR+BhVk7FzQVV8D8w5x1Q==",
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@catloversg/steamworks.js/-/steamworks.js-0.0.2.tgz",
|
||||
"integrity": "sha512-EPB7vQFZa0zGw+Ft4SHiHIDZ7UcuM/XUiyzPo5a9Pf+g5XmcvjIEjo8wKwk7Ox0DOjmSJ+s8GmOD/TDDQW5jgg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
"buildResources": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"@catloversg/steamworks.js": "0.0.1",
|
||||
"@catloversg/steamworks.js": "0.0.2",
|
||||
"electron-log": "^4.4.8",
|
||||
"electron-store": "^8.1.0",
|
||||
"lodash": "^4.17.21"
|
||||
|
||||
Reference in New Issue
Block a user