Skip to content

fix: don't unpack root dir of unpacked path hierarchy #9088

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/witty-countries-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-builder-lib": patch
---

fix: don't unpack root dir of unpacked path hierarchy
22 changes: 1 addition & 21 deletions packages/app-builder-lib/src/asar/asarUtil.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createPackageFromStreams, AsarStreamType, AsarDirectory } from "@electron/asar"
import { createPackageFromStreams, AsarStreamType } from "@electron/asar"
import { log } from "builder-util"
import { Filter } from "builder-util/out/fs"
import * as fs from "fs-extra"
Expand Down Expand Up @@ -78,8 +78,6 @@ export class AsarPackager {
return isChild || isFileUnpacked
}

this.processParentDirectories(isUnpacked, destination, results)

const result = await this.processFileOrSymlink({
file,
destination,
Expand All @@ -96,24 +94,6 @@ export class AsarPackager {
return results
}

private processParentDirectories(isUnpacked: (path: string) => boolean, destination: string, results: AsarStreamType[]) {
// process parent directories
let superDir = path.dirname(path.normalize(destination))
while (superDir !== ".") {
const dir: AsarDirectory = {
type: "directory",
path: superDir,
unpacked: isUnpacked(superDir),
}
// add to results if not already present
if (!results.some(r => r.path === dir.path)) {
results.push(dir)
}

superDir = path.dirname(superDir)
}
}

private async processFileOrSymlink(options: {
file: string
destination: string
Expand Down
22 changes: 0 additions & 22 deletions test/snapshots/BuildTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1065,10 +1065,8 @@ exports[`posix smart unpack 3`] = `
"unpacked": true,
},
},
"unpacked": true,
},
},
"unpacked": true,
},
"lib": {
"files": {
Expand All @@ -1077,14 +1075,12 @@ exports[`posix smart unpack 3`] = `
"unpacked": true,
},
},
"unpacked": true,
},
"package.json": {
"size": "<size>",
"unpacked": true,
},
},
"unpacked": true,
},
"mimic-response": {
"files": {
Expand Down Expand Up @@ -5149,7 +5145,6 @@ exports[`smart unpack local module with dll file 2`] = `
"unpacked": true,
},
},
"unpacked": true,
},
"edge-cs.dll": {
"size": "<size>",
Expand All @@ -5160,7 +5155,6 @@ exports[`smart unpack local module with dll file 2`] = `
"unpacked": true,
},
},
"unpacked": true,
},
"package.json": {
"size": "<size>",
Expand All @@ -5187,7 +5181,6 @@ exports[`smart unpack local module with dll file 2`] = `
"unpacked": true,
},
},
"unpacked": true,
},
"edge-cs": {
"files": {
Expand All @@ -5202,13 +5195,10 @@ exports[`smart unpack local module with dll file 2`] = `
"unpacked": true,
},
},
"unpacked": true,
},
},
"unpacked": true,
},
},
"unpacked": true,
},
"tools": {
"files": {
Expand All @@ -5217,10 +5207,8 @@ exports[`smart unpack local module with dll file 2`] = `
"unpacked": true,
},
},
"unpacked": true,
},
},
"unpacked": true,
},
"foo": {
"files": {
Expand All @@ -5233,7 +5221,6 @@ exports[`smart unpack local module with dll file 2`] = `
"unpacked": true,
},
},
"unpacked": true,
},
"ms": {
"files": {
Expand Down Expand Up @@ -5360,7 +5347,6 @@ exports[`win smart unpack 2`] = `
"unpacked": true,
},
},
"unpacked": true,
},
"test-smart-unpack-empty": {
"files": {
Expand Down Expand Up @@ -5422,7 +5408,6 @@ exports[`win smart unpack 2`] = `
"unpacked": true,
},
},
"unpacked": true,
},
"edge-cs.dll": {
"size": "<size>",
Expand All @@ -5433,7 +5418,6 @@ exports[`win smart unpack 2`] = `
"unpacked": true,
},
},
"unpacked": true,
},
"package.json": {
"size": "<size>",
Expand All @@ -5460,7 +5444,6 @@ exports[`win smart unpack 2`] = `
"unpacked": true,
},
},
"unpacked": true,
},
"edge-cs": {
"files": {
Expand All @@ -5475,13 +5458,10 @@ exports[`win smart unpack 2`] = `
"unpacked": true,
},
},
"unpacked": true,
},
},
"unpacked": true,
},
},
"unpacked": true,
},
"tools": {
"files": {
Expand All @@ -5490,10 +5470,8 @@ exports[`win smart unpack 2`] = `
"unpacked": true,
},
},
"unpacked": true,
},
},
"unpacked": true,
},
"ms": {
"files": {
Expand Down
17 changes: 0 additions & 17 deletions test/snapshots/globTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ exports[`isInstallDepsBefore=true > asarUnpack node_modules 2`] = `
"unpacked": true,
},
},
"unpacked": true,
},
},
"unpacked": true,
}
`;

Expand Down Expand Up @@ -9883,7 +9881,6 @@ exports[`isInstallDepsBefore=true > symlinks everywhere with static framework 3`
"unpacked": true,
},
},
"unpacked": true,
},
"Hello": {
"size": "<size>",
Expand Down Expand Up @@ -9930,7 +9927,6 @@ exports[`isInstallDepsBefore=true > symlinks everywhere with static framework 3`
"unpacked": true,
},
},
"unpacked": true,
},
"Hello.swiftsourceinfo": {
"size": "<size>",
Expand All @@ -9941,33 +9937,26 @@ exports[`isInstallDepsBefore=true > symlinks everywhere with static framework 3`
"unpacked": true,
},
},
"unpacked": true,
},
},
"unpacked": true,
},
"Current": {
"link": "node_modules/hello-world/lib/Release/Hello.framework/Versions/A",
"unpacked": true,
},
},
"unpacked": true,
},
},
"unpacked": true,
},
},
"unpacked": true,
},
},
"unpacked": true,
},
"package.json": {
"size": "<size>",
"unpacked": true,
},
},
"unpacked": true,
},
"ms": {
"files": {
Expand Down Expand Up @@ -10111,10 +10100,8 @@ exports[`unpackDir 2`] = `
"unpacked": true,
},
},
"unpacked": true,
},
},
"unpacked": true,
},
"b2": {
"files": {
Expand All @@ -10123,7 +10110,6 @@ exports[`unpackDir 2`] = `
"unpacked": true,
},
},
"unpacked": true,
},
"do-not-unpack-dir": {
"files": {
Expand Down Expand Up @@ -10230,10 +10216,8 @@ exports[`unpackDir one 2`] = `
"unpacked": true,
},
},
"unpacked": true,
},
},
"unpacked": true,
},
"b2": {
"files": {
Expand All @@ -10242,7 +10226,6 @@ exports[`unpackDir one 2`] = `
"unpacked": true,
},
},
"unpacked": true,
},
"do-not-unpack-dir": {
"files": {
Expand Down
Loading