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:
commit
d105573665
4 changed files with 4 additions and 8 deletions
|
@ -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",
|
||||
|
|
|
@ -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() );
|
||||
}
|
||||
|
||||
|
|
|
@ -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
BIN
yarn.lock
Binary file not shown.
Loading…
Reference in a new issue