From 5c7ba1c2c4851a0cfb339176565a45cc6252b204 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20R=C3=BCger?= Date: Sat, 24 Sep 2022 14:13:56 +0200 Subject: [PATCH 1/2] fix recursion problem --- lib/fs-wrapper.js | 4 ++-- lib/util/index.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/fs-wrapper.js b/lib/fs-wrapper.js index 0e265ec..25da443 100644 --- a/lib/fs-wrapper.js +++ b/lib/fs-wrapper.js @@ -303,7 +303,7 @@ function overwriteFs () { overwrite('statSync', (statSync) => { return function (p, options) { p = bufferToString(p) - const pathInfo = splitPath(path.resolve(p)) + const pathInfo = options?.outsideAsar ? { isAsar: false } : splitPath(path.resolve(p)) const { isAsar, asarPath, filePath } = pathInfo if (!isAsar) return statSync.apply(this, arguments) @@ -347,7 +347,7 @@ function overwriteFs () { overwrite('lstatSync', (lstatSync) => { return function (p, options) { p = bufferToString(p) - const { isAsar, asarPath, filePath } = splitPath(path.resolve(p)) + const { isAsar, asarPath, filePath } = options?.outsideAsar ? { isAsar: false } : splitPath(path.resolve(p)) if (!isAsar) return lstatSync.apply(this, arguments) const archive = getOrCreateArchive(asarPath) diff --git a/lib/util/index.js b/lib/util/index.js index c27070e..e45cb37 100644 --- a/lib/util/index.js +++ b/lib/util/index.js @@ -43,7 +43,7 @@ function splitPath (archivePath) { if (isAsarDisabled()) return r if (typeof archivePath !== 'string') return r if (archivePath.endsWith('.asar')) { - if (existsSync(archivePath) && statSync(archivePath).isFile()) { + if (existsSync(archivePath) && statSync(archivePath, { outsideAsar: true }).isFile()) { r.isAsar = true r.asarPath = tryRedirectUnpacked(archivePath) r.filePath = '' From 2f280e6a7138431e6d07e9e3442e95802282b2bd Mon Sep 17 00:00:00 2001 From: toyobayashi Date: Sun, 25 Sep 2022 14:29:31 +0800 Subject: [PATCH 2/2] fix: electron 17+ worker_threads maximum call stack size exceeded --- lib/fs-wrapper.js | 4 ++-- lib/util/index.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/fs-wrapper.js b/lib/fs-wrapper.js index 25da443..0e265ec 100644 --- a/lib/fs-wrapper.js +++ b/lib/fs-wrapper.js @@ -303,7 +303,7 @@ function overwriteFs () { overwrite('statSync', (statSync) => { return function (p, options) { p = bufferToString(p) - const pathInfo = options?.outsideAsar ? { isAsar: false } : splitPath(path.resolve(p)) + const pathInfo = splitPath(path.resolve(p)) const { isAsar, asarPath, filePath } = pathInfo if (!isAsar) return statSync.apply(this, arguments) @@ -347,7 +347,7 @@ function overwriteFs () { overwrite('lstatSync', (lstatSync) => { return function (p, options) { p = bufferToString(p) - const { isAsar, asarPath, filePath } = options?.outsideAsar ? { isAsar: false } : splitPath(path.resolve(p)) + const { isAsar, asarPath, filePath } = splitPath(path.resolve(p)) if (!isAsar) return lstatSync.apply(this, arguments) const archive = getOrCreateArchive(asarPath) diff --git a/lib/util/index.js b/lib/util/index.js index e45cb37..69dec00 100644 --- a/lib/util/index.js +++ b/lib/util/index.js @@ -1,5 +1,5 @@ const { - statSync, + lstatSync, existsSync, openSync, readSync, @@ -43,7 +43,7 @@ function splitPath (archivePath) { if (isAsarDisabled()) return r if (typeof archivePath !== 'string') return r if (archivePath.endsWith('.asar')) { - if (existsSync(archivePath) && statSync(archivePath, { outsideAsar: true }).isFile()) { + if (existsSync(archivePath) && lstatSync(archivePath).isFile()) { r.isAsar = true r.asarPath = tryRedirectUnpacked(archivePath) r.filePath = '' @@ -57,7 +57,7 @@ function splitPath (archivePath) { const archive = archivePath.substring(0, index + 5) - if (existsSync(archive) && statSync(archive).isFile()) { + if (existsSync(archive) && lstatSync(archive).isFile()) { r.isAsar = true r.asarPath = tryRedirectUnpacked(archive) r.filePath = archivePath.substring(index + 6)