From f858f9e0b43de8d646cce7ac4e9c00f773c2f131 Mon Sep 17 00:00:00 2001 From: Uzair Sajid Date: Tue, 22 Oct 2019 23:08:31 +0500 Subject: [PATCH] fix(mac): make tempFile unique for each call to getProvisioningProfileAsync (#4269) When building multiple targets on macOS, getProvisioningProfileAsync would create a temporary plist file that was shared between targets. However this method also unlinked the file it created causing the other target, which was running in parallel to crash. This fix makes the temporary file name unique for each call to getProvisioningProfileAsync so when the method unlinks the file, it doesn't cause other targets building in parallel to fail. fixes #4204 --- .../electron-osx-sign/util-provisioning-profiles.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/app-builder-lib/electron-osx-sign/util-provisioning-profiles.js b/packages/app-builder-lib/electron-osx-sign/util-provisioning-profiles.js index 1281dac4230..e7c104c0e5f 100644 --- a/packages/app-builder-lib/electron-osx-sign/util-provisioning-profiles.js +++ b/packages/app-builder-lib/electron-osx-sign/util-provisioning-profiles.js @@ -71,8 +71,13 @@ var getProvisioningProfileAsync = module.exports.getProvisioningProfileAsync = f return execFileAsync('security', securityArgs) .then(async function (result) { + // make filename unique so it doesn't create issues with parallel method calls + const timestamp = process.hrtime.bigint + ? process.hrtime.bigint().toString() + : process.hrtime().join('') + // todo read directly - const tempFile = path.join(os.tmpdir(), `${require('crypto').createHash('sha1').update(filePath).digest("hex")}.plist`) + const tempFile = path.join(os.tmpdir(), `${require('crypto').createHash('sha1').update(filePath).update(timestamp).digest('hex')}.plist`) await fs.outputFile(tempFile, result) const plistContent = await executeAppBuilderAsJson(["decode-plist", "-f", tempFile]) await fs.unlink(tempFile)