Pass response text code and message for tagged response in append and move

fork
Chotiwat Chawannakul 12 years ago
parent 69d23e446f
commit 6f2adf53e3

@ -893,9 +893,9 @@ ImapConnection.prototype.append = function(data, options, cb) {
cmd += (Buffer.isBuffer(data) ? data.length : Buffer.byteLength(data));
cmd += '}';
var self = this, step = 1;
this._send(cmd, function(err) {
this._send(cmd, function(err, info) {
if (err || step++ === 2)
return cb(err);
return cb(err, info);
self._state.conn.write(data);
self._state.conn.write(CRLF);
self.debug&&self.debug('\n==> ' + inspect(data.toString()) + '\n');
@ -1314,44 +1314,44 @@ ImapConnection.prototype._move = function(which, uids, boxTo, cb) {
throw new Error('Cannot move message: '
+ 'server does not allow deletion of messages');
} else {
this._copy(which, uids, boxTo, function ccb(err, reentryCount, deletedUIDs,
this._copy(which, uids, boxTo, function ccb(err, info, reentryCount, deletedUIDs,
counter) {
if (err)
return cb(err);
return cb(err, info);
counter = counter || 0;
// Make sure we don't expunge any messages marked as Deleted except the
// one we are moving
if (reentryCount === undefined) {
self.search(['DELETED'], function(e, result) {
ccb(e, 1, result);
ccb(e, info, 1, result);
});
} else if (reentryCount === 1) {
if (counter < deletedUIDs.length) {
self.delFlags(deletedUIDs[counter], 'Deleted', function(e) {
process.nextTick(function() {
ccb(e, reentryCount, deletedUIDs, counter + 1);
ccb(e, info, reentryCount, deletedUIDs, counter + 1);
});
});
} else
ccb(err, reentryCount + 1, deletedUIDs);
ccb(err, info, reentryCount + 1, deletedUIDs);
} else if (reentryCount === 2) {
self.addFlags(uids, 'Deleted', function(e) {
ccb(e, reentryCount + 1, deletedUIDs);
ccb(e, info, reentryCount + 1, deletedUIDs);
});
} else if (reentryCount === 3) {
self.removeDeleted(function(e) {
ccb(e, reentryCount + 1, deletedUIDs);
ccb(e, info, reentryCount + 1, deletedUIDs);
});
} else if (reentryCount === 4) {
if (counter < deletedUIDs.length) {
self.addFlags(deletedUIDs[counter], 'Deleted', function(e) {
process.nextTick(function() {
ccb(e, reentryCount, deletedUIDs, counter + 1);
ccb(e, info, reentryCount, deletedUIDs, counter + 1);
});
});
} else
cb();
cb(err, info);
}
});
}

Loading…
Cancel
Save