From 436a2761b2d3fb31034e9e2ce3aa72142941b9a4 Mon Sep 17 00:00:00 2001 From: Ronnie Date: Fri, 4 Oct 2013 11:38:18 +0200 Subject: [PATCH 1/2] esearch should call _esearch and return data to callback. Removed space in _esearch command and put it before encode, as query already has a space --- lib/Connection.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Connection.js b/lib/Connection.js index 4b2cd5c..c4ceba2 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -829,7 +829,7 @@ Connection.prototype._sort = function(which, sorts, criteria, cb) { }; Connection.prototype.esearch = function(criteria, options, cb) { - this._search('UID ', criteria, options, cb); + this._esearch('UID ', criteria, options, cb); }; Connection.prototype._esearch = function(which, criteria, options, cb) { @@ -843,7 +843,7 @@ Connection.prototype._esearch = function(which, criteria, options, cb) { charset = '', lines; if (info.hasUTF8) { - charset = 'CHARSET UTF-8'; + charset = ' CHARSET UTF-8'; lines = query.split(CRLF); query = lines.shift(); } @@ -857,7 +857,7 @@ Connection.prototype._esearch = function(which, criteria, options, cb) { if (Array.isArray(options)) options = options.join(' '); - this._enqueue(which + 'SEARCH RETURN (' + options + ') ' + charset + query, cb); + this._enqueue(which + 'SEARCH RETURN (' + options + ')' + charset + query, cb); if (info.hasUTF8) { var req = this._queue[this._queue.length - 1]; req.lines = lines; @@ -1098,7 +1098,9 @@ Connection.prototype._resUntagged = function(info) { else if (type === 'preauth') this.state = 'authenticated'; else if (type === 'sort' || type === 'thread') - this._curReq.cbargs.push(info.text); + this._curReq.cbargs.push(info.text); + else if (type === 'esearch') + this._curReq.cbargs.push(info.text); else if (type === 'search') { if (info.text.results !== undefined) { // CONDSTORE-modified search results From 91fd2d15124e9ed0619b2453cda45ae56fd710cb Mon Sep 17 00:00:00 2001 From: Ronnie Date: Fri, 4 Oct 2013 13:52:58 +0200 Subject: [PATCH 2/2] Removed separate if for esearch result --- lib/Connection.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/Connection.js b/lib/Connection.js index c4ceba2..73a7e2e 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -1097,10 +1097,8 @@ Connection.prototype._resUntagged = function(info) { this._caps = info.text.map(function(v) { return v.toUpperCase(); }); else if (type === 'preauth') this.state = 'authenticated'; - else if (type === 'sort' || type === 'thread') - this._curReq.cbargs.push(info.text); - else if (type === 'esearch') - this._curReq.cbargs.push(info.text); + else if (type === 'sort' || type === 'thread' || type === 'esearch') + this._curReq.cbargs.push(info.text); else if (type === 'search') { if (info.text.results !== undefined) { // CONDSTORE-modified search results