mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-01-06 22:40:26 -05:00
Merge pull request #1240 from verdaccio/fix-1191
fix: overrides existing package to zero bytes file #1191
This commit is contained in:
commit
d105573665
4 changed files with 4 additions and 8 deletions
|
@ -15,7 +15,7 @@
|
||||||
"verdaccio": "./bin/verdaccio"
|
"verdaccio": "./bin/verdaccio"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@verdaccio/local-storage": "1.1.6",
|
"@verdaccio/local-storage": "1.1.7",
|
||||||
"@verdaccio/streams": "1.0.0",
|
"@verdaccio/streams": "1.0.0",
|
||||||
"JSONStream": "1.3.5",
|
"JSONStream": "1.3.5",
|
||||||
"async": "3.0.1-0",
|
"async": "3.0.1-0",
|
||||||
|
|
|
@ -222,7 +222,9 @@ class LocalStorage implements IStorage {
|
||||||
metadata = cleanUpReadme(metadata);
|
metadata = cleanUpReadme(metadata);
|
||||||
metadata.contributors = normalizeContributors(metadata.contributors);
|
metadata.contributors = normalizeContributors(metadata.contributors);
|
||||||
|
|
||||||
if (data.versions[version] != null) {
|
|
||||||
|
const hasVersion = data.versions[version] != null;
|
||||||
|
if (hasVersion) {
|
||||||
return cb( ErrorCode.getConflict() );
|
return cb( ErrorCode.getConflict() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -364,16 +364,10 @@ describe('LocalStorage', () => {
|
||||||
test('should fails on add a duplicated new tarball ', (done) => {
|
test('should fails on add a duplicated new tarball ', (done) => {
|
||||||
const tarballData = JSON.parse(readMetadata('addTarball'));
|
const tarballData = JSON.parse(readMetadata('addTarball'));
|
||||||
const stream = storage.addTarball(pkgName, tarballName);
|
const stream = storage.addTarball(pkgName, tarballName);
|
||||||
let spy;
|
|
||||||
// $FlowFixMe
|
|
||||||
spy = jest.spyOn(stream && stream._readableState && stream._readableState.pipes, 'abort');
|
|
||||||
stream.on('error', (err) => {
|
stream.on('error', (err) => {
|
||||||
expect(err).not.toBeNull();
|
expect(err).not.toBeNull();
|
||||||
expect(err.statusCode).toEqual(HTTP_STATUS.CONFLICT);
|
expect(err.statusCode).toEqual(HTTP_STATUS.CONFLICT);
|
||||||
expect(err.message).toMatch(/this package is already present/);
|
expect(err.message).toMatch(/this package is already present/);
|
||||||
});
|
|
||||||
stream.on('success', function(){
|
|
||||||
expect(spy).toHaveBeenCalled();
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
stream.end(new Buffer(tarballData.data, 'base64'));
|
stream.end(new Buffer(tarballData.data, 'base64'));
|
||||||
|
|
BIN
yarn.lock
BIN
yarn.lock
Binary file not shown.
Loading…
Reference in a new issue