diff --git a/package.json b/package.json index 5f16a25bb..a659176f1 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/lib/local-storage.js b/src/lib/local-storage.js index 2bd3ac9a3..f854bd5fd 100644 --- a/src/lib/local-storage.js +++ b/src/lib/local-storage.js @@ -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() ); } diff --git a/test/unit/api/local-storage.spec.js b/test/unit/api/local-storage.spec.js index 8d398c767..2e4f93234 100644 --- a/test/unit/api/local-storage.spec.js +++ b/test/unit/api/local-storage.spec.js @@ -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')); diff --git a/yarn.lock b/yarn.lock index 4b2ad2765..542ea5d7c 100644 Binary files a/yarn.lock and b/yarn.lock differ