0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-06 22:40:26 -05:00

fix: overrides existing package to zero bytes file #1191

Publishing existing package overrides existing package to 0 bytes file
This commit is contained in:
Juan Picado @jotadeveloper 2019-02-24 10:11:56 +01:00
parent 098ab90576
commit d470cfeeed
No known key found for this signature in database
GPG key ID: 18AC54485952D158
4 changed files with 4 additions and 8 deletions

View file

@ -16,7 +16,7 @@
},
"dependencies": {
"@verdaccio/file-locking": "0.0.8",
"@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.