From af333aab19b1e7f59c654c2eca500937d0c36f23 Mon Sep 17 00:00:00 2001 From: Konstantin Raev Date: Fri, 23 Jun 2017 18:39:15 -0700 Subject: [PATCH] fixes for Mael --- .../commands/install/integration-deduping.js | 48 ++++++++++++++++-- .../deps/a-1/package.json | 7 +++ .../deps/b-1/package.json | 7 +++ .../deps/b-2/package.json | 4 ++ .../deps/c-1/package.json | 4 ++ .../deps/c-2/package.json | 4 ++ .../deps/c-3/package.json | 4 ++ .../deps/d-1/package.json | 8 +++ .../install/hardlink-collision-3/package.json | 8 +++ .../deps/a-1/package.json | 8 +++ .../deps/b-1/package.json | 7 +++ .../deps/b-2/package.json | 4 ++ .../deps/c-1/c-1.0.0.tgz | Bin 0 -> 4854 bytes .../deps/c-2/package.json | 4 ++ .../deps/c-3/package.json | 4 ++ .../deps/d-1/package.json | 8 +++ .../package.json | 8 +++ src/fetchers/tarball-fetcher.js | 8 ++- src/resolvers/exotics/tarball-resolver.js | 3 +- src/util/fs.js | 6 ++- 20 files changed, 145 insertions(+), 9 deletions(-) create mode 100644 __tests__/fixtures/install/hardlink-collision-3/deps/a-1/package.json create mode 100644 __tests__/fixtures/install/hardlink-collision-3/deps/b-1/package.json create mode 100644 __tests__/fixtures/install/hardlink-collision-3/deps/b-2/package.json create mode 100644 __tests__/fixtures/install/hardlink-collision-3/deps/c-1/package.json create mode 100644 __tests__/fixtures/install/hardlink-collision-3/deps/c-2/package.json create mode 100644 __tests__/fixtures/install/hardlink-collision-3/deps/c-3/package.json create mode 100644 __tests__/fixtures/install/hardlink-collision-3/deps/d-1/package.json create mode 100644 __tests__/fixtures/install/hardlink-collision-3/package.json create mode 100644 __tests__/fixtures/install/hardlink-collision-with-bundled/deps/a-1/package.json create mode 100644 __tests__/fixtures/install/hardlink-collision-with-bundled/deps/b-1/package.json create mode 100644 __tests__/fixtures/install/hardlink-collision-with-bundled/deps/b-2/package.json create mode 100644 __tests__/fixtures/install/hardlink-collision-with-bundled/deps/c-1/c-1.0.0.tgz create mode 100644 __tests__/fixtures/install/hardlink-collision-with-bundled/deps/c-2/package.json create mode 100644 __tests__/fixtures/install/hardlink-collision-with-bundled/deps/c-3/package.json create mode 100644 __tests__/fixtures/install/hardlink-collision-with-bundled/deps/d-1/package.json create mode 100644 __tests__/fixtures/install/hardlink-collision-with-bundled/package.json diff --git a/__tests__/commands/install/integration-deduping.js b/__tests__/commands/install/integration-deduping.js index 8e099e0a37..8f6e78b6f2 100644 --- a/__tests__/commands/install/integration-deduping.js +++ b/__tests__/commands/install/integration-deduping.js @@ -221,7 +221,7 @@ test.concurrent('install should not hardlink repeated dependencies if linkDuplic }); }); -test.concurrent('install should not copy node_modules when hardlinking', (): Promise => { +test.concurrent('install should not crash when hardlinking deep structures', (): Promise => { // https://github.com/yarnpkg/yarn/issues/2734 // A@1 -> B@1 -> C@1 // -> C@2 @@ -239,13 +239,13 @@ test.concurrent('install should not copy node_modules when hardlinking', (): Pro }); }); -test.concurrent('install should not hardlink full package structure', (): Promise => { +test.concurrent('install should consider different hoisting with --link-duplicate', (): Promise => { // https://github.com/yarnpkg/yarn/issues/2734 // A@1 -> B@1 -> C@1 // -> C@2 // B@2 // C@3 - // D@1 -> B@1 (hardlink) + // D@1 -> B@1 (hardlink) -> *C@1* (redundant) // -> C@1 (hardlink) return runInstall({linkDuplicates: true}, 'hardlink-collision-2', async config => { let a_1 = await fs.stat(path.join(config.cwd, 'node_modules/a/node_modules/b/package.json')); @@ -254,6 +254,46 @@ test.concurrent('install should not hardlink full package structure', (): Promis a_1 = await fs.stat(path.join(config.cwd, 'node_modules/a/node_modules/b/node_modules/c/package.json')); d_1 = await fs.stat(path.join(config.cwd, 'node_modules/d/node_modules/c/package.json')); expect(a_1.ino).toEqual(d_1.ino); - expect(await fs.exists(path.join(config.cwd, 'node_modules/d/node_modules/b/node_modules/c/package.json'))).toBe(false); + // this is redundant but we are ok with it + expect(await fs.exists(path.join(config.cwd, 'node_modules/d/node_modules/b/node_modules/c/package.json'))).toBe(true); + }); +}); + +test.concurrent('install should consider different hoisting with --link-duplicate 2', (): Promise => { + // https://github.com/yarnpkg/yarn/issues/2734 + // A@1 -> B@1 + // -> C@1 + // B@2 + // C@3 + // D@1 -> B@1 (hardlink) -> C@1 (hardlink) + // -> C@2 + return runInstall({linkDuplicates: true}, 'hardlink-collision-3', async config => { + let a_1 = await fs.stat(path.join(config.cwd, 'node_modules/a/node_modules/b/package.json')); + let d_1 = await fs.stat(path.join(config.cwd, 'node_modules/d/node_modules/b/package.json')); + expect(a_1.ino).toEqual(d_1.ino); + a_1 = await fs.stat(path.join(config.cwd, 'node_modules/a/node_modules/c/package.json')); + d_1 = await fs.stat(path.join(config.cwd, 'node_modules/d/node_modules/b/node_modules/c/package.json')); + expect(a_1.ino).toEqual(d_1.ino); + }); +}); + +test.concurrent('install should not hardlink full package structure', (): Promise => { + // https://github.com/yarnpkg/yarn/issues/2734 + // A@1 -> B@1 -> C@1 -> (bundle leftpad) + // -> C@2 + // B@2 + // C@3 + // D@1 -> B@1 (hardlink) -> C@1 (hardlink) -> (bundle leftpad) (hardlink) + // -> C@2 + return runInstall({linkDuplicates: true}, 'hardlink-collision-with-bundled', async config => { + let a_1 = await fs.stat(path.join(config.cwd, 'node_modules/a/node_modules/b/package.json')); + let d_1 = await fs.stat(path.join(config.cwd, 'node_modules/d/node_modules/b/package.json')); + expect(a_1.ino).toEqual(d_1.ino); + a_1 = await fs.stat(path.join(config.cwd, 'node_modules/a/node_modules/b/node_modules/c/package.json')); + d_1 = await fs.stat(path.join(config.cwd, 'node_modules/d/node_modules/b/node_modules/c/package.json')); + expect(a_1.ino).toEqual(d_1.ino); + a_1 = await fs.stat(path.join(config.cwd, 'node_modules/a/node_modules/b/node_modules/c/node_modules/left-pad/package.json')); + d_1 = await fs.stat(path.join(config.cwd, 'node_modules/d/node_modules/b/node_modules/c/node_modules/left-pad/package.json')); + expect(a_1.ino).toEqual(d_1.ino); }); }); diff --git a/__tests__/fixtures/install/hardlink-collision-3/deps/a-1/package.json b/__tests__/fixtures/install/hardlink-collision-3/deps/a-1/package.json new file mode 100644 index 0000000000..f724d1e272 --- /dev/null +++ b/__tests__/fixtures/install/hardlink-collision-3/deps/a-1/package.json @@ -0,0 +1,7 @@ +{ + "name": "a", + "version": "1.0.0", + "dependencies": { + "b": "file:../b-1" + } +} diff --git a/__tests__/fixtures/install/hardlink-collision-3/deps/b-1/package.json b/__tests__/fixtures/install/hardlink-collision-3/deps/b-1/package.json new file mode 100644 index 0000000000..ad3074b214 --- /dev/null +++ b/__tests__/fixtures/install/hardlink-collision-3/deps/b-1/package.json @@ -0,0 +1,7 @@ +{ + "name": "b", + "version": "1.0.0", + "dependencies": { + "c": "file:../c-1" + } +} diff --git a/__tests__/fixtures/install/hardlink-collision-3/deps/b-2/package.json b/__tests__/fixtures/install/hardlink-collision-3/deps/b-2/package.json new file mode 100644 index 0000000000..57549744f3 --- /dev/null +++ b/__tests__/fixtures/install/hardlink-collision-3/deps/b-2/package.json @@ -0,0 +1,4 @@ +{ + "name": "b", + "version": "2.0.0" +} diff --git a/__tests__/fixtures/install/hardlink-collision-3/deps/c-1/package.json b/__tests__/fixtures/install/hardlink-collision-3/deps/c-1/package.json new file mode 100644 index 0000000000..abd3384930 --- /dev/null +++ b/__tests__/fixtures/install/hardlink-collision-3/deps/c-1/package.json @@ -0,0 +1,4 @@ +{ + "name": "c", + "version": "1.0.0" +} diff --git a/__tests__/fixtures/install/hardlink-collision-3/deps/c-2/package.json b/__tests__/fixtures/install/hardlink-collision-3/deps/c-2/package.json new file mode 100644 index 0000000000..eede1fcd97 --- /dev/null +++ b/__tests__/fixtures/install/hardlink-collision-3/deps/c-2/package.json @@ -0,0 +1,4 @@ +{ + "name": "c", + "version": "2.0.0" +} diff --git a/__tests__/fixtures/install/hardlink-collision-3/deps/c-3/package.json b/__tests__/fixtures/install/hardlink-collision-3/deps/c-3/package.json new file mode 100644 index 0000000000..6915ecb021 --- /dev/null +++ b/__tests__/fixtures/install/hardlink-collision-3/deps/c-3/package.json @@ -0,0 +1,4 @@ +{ + "name": "c", + "version": "3.0.0" +} diff --git a/__tests__/fixtures/install/hardlink-collision-3/deps/d-1/package.json b/__tests__/fixtures/install/hardlink-collision-3/deps/d-1/package.json new file mode 100644 index 0000000000..eae1f73732 --- /dev/null +++ b/__tests__/fixtures/install/hardlink-collision-3/deps/d-1/package.json @@ -0,0 +1,8 @@ +{ + "name": "a", + "version": "2.0.0", + "dependencies": { + "b": "file:../b-1", + "c": "file:../c-2" + } +} diff --git a/__tests__/fixtures/install/hardlink-collision-3/package.json b/__tests__/fixtures/install/hardlink-collision-3/package.json new file mode 100644 index 0000000000..9b49885a10 --- /dev/null +++ b/__tests__/fixtures/install/hardlink-collision-3/package.json @@ -0,0 +1,8 @@ +{ + "dependencies": { + "a": "file:deps/a-1", + "b": "file:deps/b-2", + "c": "file:deps/c-3", + "d": "file:deps/d-1" + } +} diff --git a/__tests__/fixtures/install/hardlink-collision-with-bundled/deps/a-1/package.json b/__tests__/fixtures/install/hardlink-collision-with-bundled/deps/a-1/package.json new file mode 100644 index 0000000000..c2c8651d69 --- /dev/null +++ b/__tests__/fixtures/install/hardlink-collision-with-bundled/deps/a-1/package.json @@ -0,0 +1,8 @@ +{ + "name": "a", + "version": "1.0.0", + "dependencies": { + "b": "file:../b-1", + "c": "file:../c-2" + } +} diff --git a/__tests__/fixtures/install/hardlink-collision-with-bundled/deps/b-1/package.json b/__tests__/fixtures/install/hardlink-collision-with-bundled/deps/b-1/package.json new file mode 100644 index 0000000000..f9f1b907dc --- /dev/null +++ b/__tests__/fixtures/install/hardlink-collision-with-bundled/deps/b-1/package.json @@ -0,0 +1,7 @@ +{ + "name": "b", + "version": "1.0.0", + "dependencies": { + "c": "file:../c-1/c-1.0.0.tgz" + } +} diff --git a/__tests__/fixtures/install/hardlink-collision-with-bundled/deps/b-2/package.json b/__tests__/fixtures/install/hardlink-collision-with-bundled/deps/b-2/package.json new file mode 100644 index 0000000000..57549744f3 --- /dev/null +++ b/__tests__/fixtures/install/hardlink-collision-with-bundled/deps/b-2/package.json @@ -0,0 +1,4 @@ +{ + "name": "b", + "version": "2.0.0" +} diff --git a/__tests__/fixtures/install/hardlink-collision-with-bundled/deps/c-1/c-1.0.0.tgz b/__tests__/fixtures/install/hardlink-collision-with-bundled/deps/c-1/c-1.0.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..158e620d328bd8d3b616fcb7ffdf4beb3fcfbf2c GIT binary patch literal 4854 zcmZ{mbyU;;zsIMD8zo)pL>go$jg%Ak5+fWfJ&;lqkS<|JN;w4tl!ggP=cGpnf*>Fr z(o)hrSbVPMcYf#Id+zz&_g}B`{_hp%@qF;aLqPv}tlKslUNhaPCmtrV{_7IPydR&p zYlhX{QLYj^v-D-{b?99_s8{BI$RYl@*=EPAUt}%oA&r#8uQIPjt!BDEvxX&EJ{H_4 zPlEX6+-u3941jabzEh5prbDjcgmB(Z7@wR>kz{E}TK+7K7IHpW%I9}T!`x&>B0Z&o zw-|)Ij$r$MKyd_P`D^YYi-b0 zp6J7ZfoT{WE4wlU*hynQGaWZ-hzmF$tvQ_av52~ z?(Nu97X0qdPA{RU@6`y`G`(l*#inAKM(?bxlrs$It_gp>s-P4QNIF#d)bs8mSK*W5 zVwh+aZ2Ht1U^%yyL@b?@mAgOAdOa;^=m=rf`6k1rA@}1!U_j8E)9=v2)Z6|H2vcdN zavpQ%hi)aeem|sPHI#YtMpuDqO{!XPWuVrY+lS~~b zzHpq)AzgK)>X*<-pC+@woH~nuGp_0)3NEovY5uiK=cOlaj_TjjIOiJ&dVO|+2d6y^@PzRauyMe0i+C3j;d!MqbZNZ| zE1pKxRx2`Q%ew-15fXRH&Z}UF-H`BEe$Srx?Bo7UsnUlVt>>g`DtB9+`DaSVpow2> zcMstd{z?HiZq3k3Db$~6!=ALh5eVUK38mlgphnGJktfL2>eA0mDk>QU!c+@=26zFb+$!l?h>EK^ zDSqnH=z9?xlSztV?3yqAHHhOPuZ4dun~810Gh6VQKW<*<7%zW|k~7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/install/hardlink-collision-with-bundled/deps/c-2/package.json new file mode 100644 index 0000000000..eede1fcd97 --- /dev/null +++ b/__tests__/fixtures/install/hardlink-collision-with-bundled/deps/c-2/package.json @@ -0,0 +1,4 @@ +{ + "name": "c", + "version": "2.0.0" +} diff --git a/__tests__/fixtures/install/hardlink-collision-with-bundled/deps/c-3/package.json b/__tests__/fixtures/install/hardlink-collision-with-bundled/deps/c-3/package.json new file mode 100644 index 0000000000..6915ecb021 --- /dev/null +++ b/__tests__/fixtures/install/hardlink-collision-with-bundled/deps/c-3/package.json @@ -0,0 +1,4 @@ +{ + "name": "c", + "version": "3.0.0" +} diff --git a/__tests__/fixtures/install/hardlink-collision-with-bundled/deps/d-1/package.json b/__tests__/fixtures/install/hardlink-collision-with-bundled/deps/d-1/package.json new file mode 100644 index 0000000000..eae1f73732 --- /dev/null +++ b/__tests__/fixtures/install/hardlink-collision-with-bundled/deps/d-1/package.json @@ -0,0 +1,8 @@ +{ + "name": "a", + "version": "2.0.0", + "dependencies": { + "b": "file:../b-1", + "c": "file:../c-2" + } +} diff --git a/__tests__/fixtures/install/hardlink-collision-with-bundled/package.json b/__tests__/fixtures/install/hardlink-collision-with-bundled/package.json new file mode 100644 index 0000000000..9b49885a10 --- /dev/null +++ b/__tests__/fixtures/install/hardlink-collision-with-bundled/package.json @@ -0,0 +1,8 @@ +{ + "dependencies": { + "a": "file:deps/a-1", + "b": "file:deps/b-2", + "c": "file:deps/c-3", + "d": "file:deps/d-1" + } +} diff --git a/src/fetchers/tarball-fetcher.js b/src/fetchers/tarball-fetcher.js index 51d53029b5..cb1dfdf321 100644 --- a/src/fetchers/tarball-fetcher.js +++ b/src/fetchers/tarball-fetcher.js @@ -14,6 +14,7 @@ const url = require('url'); const fs = require('fs'); const stream = require('stream'); const gunzip = require('gunzip-maybe'); +import {removePrefix} from '../util/misc.js'; export default class TarballFetcher extends BaseFetcher { async setupMirrorFromCache(): Promise { @@ -174,13 +175,16 @@ export default class TarballFetcher extends BaseFetcher { } async _fetch(): Promise { + const isFilePath = this.reference.startsWith('file:'); + this.reference = removePrefix(this.reference, 'file:'); const urlParse = url.parse(this.reference); - const isFilePath = urlParse.protocol + // legacy support for local paths in yarn.lock entries + const isRelativePath = urlParse.protocol ? urlParse.protocol.match(/^[a-z]:$/i) : urlParse.pathname ? urlParse.pathname.match(/^(?:\.{1,2})?[\\\/]/) : false; - if (isFilePath) { + if (isFilePath || isRelativePath) { return this.fetchFromLocal(this.reference); } diff --git a/src/resolvers/exotics/tarball-resolver.js b/src/resolvers/exotics/tarball-resolver.js index b3eb45adeb..12b40f0c18 100644 --- a/src/resolvers/exotics/tarball-resolver.js +++ b/src/resolvers/exotics/tarball-resolver.js @@ -5,7 +5,6 @@ import type PackageRequest from '../../package-request.js'; import TarballFetcher from '../../fetchers/tarball-fetcher.js'; import ExoticResolver from './exotic-resolver.js'; import Git from './git-resolver.js'; -import {removePrefix} from '../../util/misc.js'; import guessName from '../../util/guess-name.js'; import * as versionUtil from '../../util/version.js'; import * as crypto from '../../util/crypto.js'; @@ -52,7 +51,7 @@ export default class TarballResolver extends ExoticResolver { return shrunk; } - const url = removePrefix(this.url, 'file:'); + const url = this.url; let {hash, registry} = this; let pkgJson; diff --git a/src/util/fs.js b/src/util/fs.js index f1123ec872..386ba6c268 100644 --- a/src/util/fs.js +++ b/src/util/fs.js @@ -360,6 +360,11 @@ async function buildActionsForHardlink( const {src, dest} = data; const onFresh = data.onFresh || noop; const onDone = data.onDone || noop; + if (files.has(dest)) { + // don't hardlink a file twice + onDone(); + return; + } files.add(dest); if (events.ignoreBasenames.indexOf(path.basename(src)) >= 0) { @@ -450,7 +455,6 @@ async function buildActionsForHardlink( // push all files to queue invariant(srcFiles, 'src files not initialised'); - srcFiles = srcFiles.filter(f => f !== 'node_modules'); let remaining = srcFiles.length; if (!remaining) { onDone();