0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

Merge pull request #1240 from verdaccio/fix-1191

fix: overrides existing package to zero bytes file #1191
This commit is contained in:
Juan Picado @jotadeveloper 2019-02-25 19:24:27 +01:00 committed by GitHub
commit d105573665
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 8 deletions

View file

@ -15,7 +15,7 @@
"verdaccio": "./bin/verdaccio"
},
"dependencies": {
"@verdaccio/local-storage": "1.1.6",
"@verdaccio/local-storage": "1.1.7",
"@verdaccio/streams": "1.0.0",
"JSONStream": "1.3.5",
"async": "3.0.1-0",

View file

@ -222,7 +222,9 @@ class LocalStorage implements IStorage {
metadata = cleanUpReadme(metadata);
metadata.contributors = normalizeContributors(metadata.contributors);
if (data.versions[version] != null) {
const hasVersion = data.versions[version] != null;
if (hasVersion) {
return cb( ErrorCode.getConflict() );
}

View file

@ -364,16 +364,10 @@ describe('LocalStorage', () => {
test('should fails on add a duplicated new tarball ', (done) => {
const tarballData = JSON.parse(readMetadata('addTarball'));
const stream = storage.addTarball(pkgName, tarballName);
let spy;
// $FlowFixMe
spy = jest.spyOn(stream && stream._readableState && stream._readableState.pipes, 'abort');
stream.on('error', (err) => {
expect(err).not.toBeNull();
expect(err.statusCode).toEqual(HTTP_STATUS.CONFLICT);
expect(err.message).toMatch(/this package is already present/);
});
stream.on('success', function(){
expect(spy).toHaveBeenCalled();
done();
});
stream.end(new Buffer(tarballData.data, 'base64'));

BIN
yarn.lock

Binary file not shown.