Connection: add guard when updating name of currently open box during rename

fork
Brian White 11 years ago
parent f83449f801
commit 9a961cc35c

@ -410,12 +410,6 @@ Connection.prototype.delBox = function(name, cb) {
};
Connection.prototype.renameBox = function(oldname, newname, cb) {
var destname = newname;
if (this._box
&& oldname === this._box.name
&& oldname.toUpperCase() !== 'INBOX')
destname = ''+oldname;
var encoldname = escape(utf7.encode(''+oldname)),
encnewname = escape(utf7.encode(''+newname)),
self = this;
@ -424,8 +418,14 @@ Connection.prototype.renameBox = function(oldname, newname, cb) {
function(err) {
if (err)
return cb(err);
self._box.name = destname;
cb(err, self._box);
if (self._box
&& self._box.name === oldname
&& oldname.toUpperCase() !== 'INBOX') {
self._box.name = newname;
cb(err, self._box);
} else
cb();
}
);
};

Loading…
Cancel
Save