From 277f1023c99687f9638aa92b6106532948246fdc Mon Sep 17 00:00:00 2001 From: Brian Peacock Date: Thu, 8 May 2014 16:48:15 -0500 Subject: [PATCH] Fixed unpublish --- lib/index.js | 6 ++++-- lib/local-list.js | 2 +- lib/local-storage.js | 3 ++- lib/search.js | 5 +++++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/index.js b/lib/index.js index 5dbd784a3..796a341a3 100644 --- a/lib/index.js +++ b/lib/index.js @@ -248,8 +248,10 @@ module.exports = function(config_hash) { packages = []; var getData = function(i) { - storage.get_package(results[i].ref, function(err, package) { - packages.push(package.versions[package['dist-tags'].latest]); + storage.get_package(results[i].ref, function(err, entry) { + if(entry) { + packages.push(entry.versions[entry['dist-tags'].latest]); + } if(i >= results.length - 1) { res.send(packages); diff --git a/lib/local-list.js b/lib/local-list.js index 042af2ea7..64d5bbd04 100644 --- a/lib/local-list.js +++ b/lib/local-list.js @@ -17,7 +17,7 @@ LocalList.prototype = { this.sync(); } }, - remove: function() { + remove: function(name) { var i = this.list.indexOf(name); if(i != -1) { this.list.splice(i, 1); diff --git a/lib/local-storage.js b/lib/local-storage.js index 43cbdcfa1..da23e1628 100644 --- a/lib/local-storage.js +++ b/lib/local-storage.js @@ -102,7 +102,8 @@ Storage.prototype.remove_package = function(name, callback) { }); }); }); - + + search.remove(name); localList.remove(name); } diff --git a/lib/search.js b/lib/search.js index df218beb6..b142971f1 100644 --- a/lib/search.js +++ b/lib/search.js @@ -22,6 +22,11 @@ Search.prototype = { author: package._npmUser.name }); }, + remove: function(name) { + this.index.remove({ + id: name + }); + }, reindex: function() { var self = this; this.storage.get_local(function(err, packages) {