1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix tar file being removed before extension install

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2021-05-01 11:22:33 -04:00
parent bf0dc84c22
commit 09981824b9

View File

@ -172,8 +172,16 @@ async function createTempFilesAndValidate({ fileName, dataP }: InstallRequest, d
// validate packages // validate packages
const tempFile = getExtensionPackageTemp(fileName); const tempFile = getExtensionPackageTemp(fileName);
let id: string | undefined = undefined;
disposer.push(() => fse.unlink(tempFile)); disposer.push(() => {
// This is necessary so that this file is only removed on the error condition.
// if `id` is set then when the disposer is optionally called in `unpackExtension`
// this file will not be removed.
if (!id) {
fse.unlink(tempFile).catch(noop);
}
});
try { try {
const data = await dataP; const data = await dataP;
@ -184,7 +192,8 @@ async function createTempFilesAndValidate({ fileName, dataP }: InstallRequest, d
await fse.writeFile(tempFile, data); await fse.writeFile(tempFile, data);
const manifest = await validatePackage(tempFile); const manifest = await validatePackage(tempFile);
const id = path.join(extensionDiscovery.nodeModulesPath, manifest.name, "package.json");
id = path.join(extensionDiscovery.nodeModulesPath, manifest.name, "package.json");
return { return {
fileName, fileName,