Skip to content

Commit

Permalink
cache: allow cache paths to be symlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian-gierakowski committed Jan 31, 2022
1 parent e50ebaa commit 9583435
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/yarnpkg-core/sources/Cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,15 @@ export class Cache {
const [shouldMock, cachePath, checksum] = await loadPackageThroughMutex();

this.markedFiles.add(cachePath);
const realCachePath = await xfs.realpathPromise(cachePath);

let zipFs: ZipFS | undefined;

const libzip = await getLibzipPromise();

const zipFsBuilder = shouldMock
? () => makeMockPackage()
: () => new ZipFS(cachePath, {baseFs, libzip, readOnly: true});
: () => new ZipFS(realCachePath, {baseFs, libzip, readOnly: true});

const lazyFs = new LazyFS<PortablePath>(() => miscUtils.prettifySyncErrors(() => {
return zipFs = zipFsBuilder();
Expand All @@ -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();
Expand Down

0 comments on commit 9583435

Please sign in to comment.