Skip to content

Commit

Permalink
fix(installer): release lock if things go south (#5125)
Browse files Browse the repository at this point in the history
References #5110
  • Loading branch information
aslushnikov committed Jan 23, 2021
1 parent b7fd0cd commit 74816e4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/install/installer.ts
Expand Up @@ -57,10 +57,13 @@ export async function installBrowsersWithProgressBar(packagePath: string, browse
});
const linksDir = path.join(browsersPath, '.links');

await fsMkdirAsync(linksDir, { recursive: true });
await fsWriteFileAsync(path.join(linksDir, sha1(packagePath)), packagePath);
await validateCache(packagePath, browsersPath, linksDir, browserNames);
await releaseLock();
try {
await fsMkdirAsync(linksDir, { recursive: true });
await fsWriteFileAsync(path.join(linksDir, sha1(packagePath)), packagePath);
await validateCache(packagePath, browsersPath, linksDir, browserNames);
} finally {
await releaseLock();
}
}

async function validateCache(packagePath: string, browsersPath: string, linksDir: string, browserNames?: browserPaths.BrowserName[]) {
Expand Down

0 comments on commit 74816e4

Please sign in to comment.