From 958343583c24925febe24fc03eefeacd7ee2a20e Mon Sep 17 00:00:00 2001 From: Adrian Gierakowski Date: Mon, 31 Jan 2022 16:09:33 +0000 Subject: [PATCH] cache: allow cache paths to be symlinks --- packages/yarnpkg-core/sources/Cache.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/yarnpkg-core/sources/Cache.ts b/packages/yarnpkg-core/sources/Cache.ts index 10b13419f1b0..fb3a0ad23eb5 100644 --- a/packages/yarnpkg-core/sources/Cache.ts +++ b/packages/yarnpkg-core/sources/Cache.ts @@ -354,6 +354,7 @@ export class Cache { const [shouldMock, cachePath, checksum] = await loadPackageThroughMutex(); this.markedFiles.add(cachePath); + const realCachePath = await xfs.realpathPromise(cachePath); let zipFs: ZipFS | undefined; @@ -361,7 +362,7 @@ export class Cache { const zipFsBuilder = shouldMock ? () => makeMockPackage() - : () => new ZipFS(cachePath, {baseFs, libzip, readOnly: true}); + : () => new ZipFS(realCachePath, {baseFs, libzip, readOnly: true}); const lazyFs = new LazyFS(() => miscUtils.prettifySyncErrors(() => { return zipFs = zipFsBuilder(); @@ -370,8 +371,8 @@ export class Cache { }), ppath); // We use an AliasFS to speed up getRealPath calls (e.g. VirtualFetcher.ensureVirtualLink) - // (there's no need to create the lazy baseFs instance to gather the already-known cachePath) - const aliasFs = new AliasFS(cachePath, {baseFs: lazyFs, pathUtils: ppath}); + // (there's no need to create the lazy baseFs instance to gather the already-known realCachePath) + const aliasFs = new AliasFS(realCachePath, {baseFs: lazyFs, pathUtils: ppath}); const releaseFs = () => { zipFs?.discardAndClose();