diff --git a/lib/imap.js b/lib/imap.js index 014e799..8f842ab 100644 --- a/lib/imap.js +++ b/lib/imap.js @@ -1338,46 +1338,47 @@ 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, info, reentryCount, deletedUIDs, - counter) { - if (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, info, 1, result); - }); - } else if (reentryCount === 1) { - if (counter < deletedUIDs.length) { - self.delFlags(deletedUIDs[counter], 'Deleted', function(e) { - process.nextTick(function() { - ccb(e, info, reentryCount, deletedUIDs, counter + 1); - }); + this._copy(which, uids, boxTo, + function ccb(err, info, reentryCount, deletedUIDs, counter) { + if (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, info, 1, result); }); - } else - ccb(err, info, reentryCount + 1, deletedUIDs); - } else if (reentryCount === 2) { - self.addFlags(uids, 'Deleted', function(e) { - ccb(e, info, reentryCount + 1, deletedUIDs); - }); - } else if (reentryCount === 3) { - self.removeDeleted(function(e) { - 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, info, reentryCount, deletedUIDs, counter + 1); + } else if (reentryCount === 1) { + if (counter < deletedUIDs.length) { + self.delFlags(deletedUIDs[counter], 'Deleted', function(e) { + process.nextTick(function() { + ccb(e, info, reentryCount, deletedUIDs, counter + 1); + }); }); + } else + ccb(err, info, reentryCount + 1, deletedUIDs); + } else if (reentryCount === 2) { + self.addFlags(uids, 'Deleted', function(e) { + ccb(e, info, reentryCount + 1, deletedUIDs); }); - } else - cb(err, info); + } else if (reentryCount === 3) { + self.removeDeleted(function(e) { + 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, info, reentryCount, deletedUIDs, counter + 1); + }); + }); + } else + cb(err, info); + } } - }); + ); } };