Skip to content
This repository has been archived by the owner on May 14, 2018. It is now read-only.

Commit

Permalink
perf: try to unpack tarball immediatly instead of exist check
Browse files Browse the repository at this point in the history
  • Loading branch information
zkochan committed Jul 3, 2017
1 parent f820700 commit 810ecec
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -75,7 +75,7 @@
"ssri": "^4.1.3",
"symlink-dir": "^1.0.3",
"thenify": "^3.3.0",
"unpack-stream": "^2.0.0-beta.1",
"unpack-stream": "^2.0.0",
"write-json-file": "^2.0.0",
"write-pkg": "^3.1.0",
"write-yaml-file": "^1.0.0"
Expand Down
8 changes: 4 additions & 4 deletions shrinkwrap.yaml
Expand Up @@ -59,7 +59,7 @@ dependencies:
ssri: 4.1.6
symlink-dir: 1.0.3
thenify: 3.3.0
unpack-stream: 2.0.0-beta.1
unpack-stream: 2.0.0
write-json-file: 2.2.0
write-pkg: 3.1.0
write-yaml-file: 1.0.0
Expand Down Expand Up @@ -2069,14 +2069,14 @@ packages:
through: 2.3.8
resolution:
integrity: sha1-jITITVtMwo/B+fV3IDu9PLhgoWo=
/unpack-stream/2.0.0-beta.1:
/unpack-stream/2.0.0:
dependencies:
'@types/node': 7.0.33
decompress-maybe: 1.0.0
ssri: 4.1.6
tar-fs: 1.15.3
resolution:
integrity: sha1-mJt0iwP06FuGy0pvmP8RGu0mCmM=
integrity: sha1-PFpevB3voZ3LiyzkPqdJPyBOWG4=
/unquote/1.1.0:
dev: true
resolution:
Expand Down Expand Up @@ -2246,7 +2246,7 @@ specifiers:
thenify: ^3.3.0
tslint: ^5.4.2
typescript: ^2.4.1
unpack-stream: ^2.0.0-beta.1
unpack-stream: ^2.0.0
validate-commit-msg: ^2.7.0
write-json-file: ^2.0.0
write-pkg: ^3.1.0
Expand Down
18 changes: 10 additions & 8 deletions src/install/fetchResolution.ts
Expand Up @@ -4,7 +4,6 @@ import path = require('path')
import execa = require('execa')
import {IncomingMessage} from 'http'
import * as unpackStream from 'unpack-stream'
import existsFile = require('path-exists')
import dint = require('dint')
import {Resolution} from '../resolve'
import {Got} from '../network/got'
Expand Down Expand Up @@ -90,7 +89,16 @@ export function fetchFromTarball (dir: string, dist: PackageDist, opts: FetchOpt

export async function fetchFromRemoteTarball (dir: string, dist: PackageDist, opts: FetchOptions) {
const localTarballPath = path.join(opts.storePath, opts.pkgId, 'packed.tgz')
if (!await existsFile(localTarballPath)) {
try {
const index = await fetchFromLocalTarball(dir, {
integrity: dist.integrity,
tarball: localTarballPath,
})
fetchLogger.debug(`finish ${dist.integrity} ${dist.tarball}`)
return index
} catch (err) {
if (err['code'] !== 'ENOENT') throw err

if (opts.offline) {
throw new PnpmError('NO_OFFLINE_TARBALL', `Could not find ${localTarballPath} in local registry mirror ${opts.storePath}`)
}
Expand All @@ -101,12 +109,6 @@ export async function fetchFromRemoteTarball (dir: string, dist: PackageDist, op
onStart: () => logStatus({status: 'fetching', pkgId: opts.pkgId}),
})
}
const index = await fetchFromLocalTarball(dir, {
integrity: dist.integrity,
tarball: localTarballPath,
})
fetchLogger.debug(`finish ${dist.integrity} ${dist.tarball}`)
return index
}

async function fetchFromLocalTarball (
Expand Down

0 comments on commit 810ecec

Please sign in to comment.