fix: installing big git-hosted packages (#4066)

close #4064
This commit is contained in:
Zoltan Kochan
2021-12-04 02:59:40 +02:00
committed by GitHub
parent b83756bd7f
commit b13e4b4526
7 changed files with 43 additions and 7 deletions

View File

@@ -0,0 +1,9 @@
---
"@pnpm/git-fetcher": patch
"@pnpm/tarball-fetcher": patch
"pnpm": patch
---
Fixes a regression introduced in pnpm v6.23.3 via [#4044](https://github.com/pnpm/pnpm/pull/4044).
The temporary directory to which the Git-hosted package is downloaded should not be removed prematurely [#4064](https://github.com/pnpm/pnpm/issues/4064).

View File

@@ -24,7 +24,9 @@ export default () => {
// removing /.git to make directory integrity calculation faster
await rimraf(path.join(tempLocation, '.git'))
const filesIndex = await cafs.addFilesFromDir(tempLocation, opts.manifest)
await rimraf(tempLocation)
// Important! We cannot remove the temp location at this stage.
// Even though we have the index of the package,
// the linking of files to the store is in progress.
return { filesIndex }
},
}

View File

@@ -63,4 +63,18 @@ test('fetch a package without a package.json', async () => {
}
)
expect(filesIndex['denolib.json']).toBeTruthy()
})
})
// Covers the regression reported in https://github.com/pnpm/pnpm/issues/4064
test('fetch a big repository', async () => {
const cafsDir = tempy.directory()
const fetch = createFetcher().git
const manifest = pDefer<DependencyManifest>()
const { filesIndex } = await fetch(createCafsStore(cafsDir),
{
commit: 'a65fbf5a90f53c9d72fed4daaca59da50f074355',
repo: 'https://github.com/sveltejs/action-deploy-docs.git',
type: 'git',
}, { manifest })
await Promise.all(Object.values(filesIndex).map(({ writeResult }) => writeResult))
})

View File

@@ -41,7 +41,6 @@
"@pnpm/graceful-fs": "workspace:1.0.0",
"@pnpm/prepare-package": "workspace:1.0.7",
"@zkochan/retry": "^0.2.0",
"@zkochan/rimraf": "^2.1.1",
"ramda": "^0.27.1",
"ssri": "^8.0.1"
},

View File

@@ -12,7 +12,6 @@ import {
import { FetchFromRegistry } from '@pnpm/fetching-types'
import preparePackage from '@pnpm/prepare-package'
import * as retry from '@zkochan/retry'
import rimraf from '@zkochan/rimraf'
import fromPairs from 'ramda/src/fromPairs'
import omit from 'ramda/src/omit'
import ssri from 'ssri'
@@ -248,7 +247,9 @@ async function prepareGitHostedPkg (filesIndex: FilesIndex, cafs: Cafs) {
})
await preparePackage(tempLocation)
const newFilesIndex = await cafs.addFilesFromDir(tempLocation)
await rimraf(tempLocation)
// Important! We cannot remove the temp location at this stage.
// Even though we have the index of the package,
// the linking of files to the store is in progress.
return newFilesIndex
}

View File

@@ -353,3 +353,16 @@ test('accessing private packages', async () => {
async function getFileIntegrity (filename: string) {
return (await ssri.fromStream(fs.createReadStream(filename))).toString()
}
// Covers the regression reported in https://github.com/pnpm/pnpm/issues/4064
test('fetch a big repository', async () => {
process.chdir(tempy.directory())
const resolution = { tarball: 'https://codeload.github.com/sveltejs/action-deploy-docs/tar.gz/a65fbf5a90f53c9d72fed4daaca59da50f074355' }
const result = await fetch.tarball(cafs, resolution, {
lockfileDir: process.cwd(),
})
expect(result.filesIndex).toBeTruthy()
})

2
pnpm-lock.yaml generated
View File

@@ -3253,7 +3253,6 @@ importers:
'@types/retry': ^0.12.0
'@types/ssri': ^7.1.0
'@zkochan/retry': ^0.2.0
'@zkochan/rimraf': ^2.1.1
cp-file: ^9.0.0
nock: 12.0.3
ramda: ^0.27.1
@@ -3267,7 +3266,6 @@ importers:
'@pnpm/graceful-fs': link:../graceful-fs
'@pnpm/prepare-package': link:../prepare-package
'@zkochan/retry': 0.2.0
'@zkochan/rimraf': 2.1.1
ramda: 0.27.1
ssri: 8.0.1
devDependencies: