fix(dom) renameCurrent: rm dir listing from Storage

This commit is contained in:
coderaiser 2014-02-24 05:04:42 -05:00
parent dd46da4005
commit e63fa22c75

View file

@ -1604,23 +1604,29 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
*
* @pCurrent
*/
this.renameCurrent = function(pCurrentFile) {
if (!Cmd.isCurrentFile(pCurrentFile))
pCurrentFile = null;
this.renameCurrent = function(current) {
var from, to, dirPath, cmp, files;
var lCurrent = pCurrentFile || Cmd.getCurrentFile(),
lFrom = Cmd.getCurrentName(lCurrent),
lTo = Dialog.prompt('Rename', lFrom) || lFrom,
lDirPath = Cmd.getCurrentDirPath();
if (!Cmd.isCurrentFile(current))
current = Cmd.getCurrentFile();
if (!Util.strCmp(lFrom, lTo)) {
var lFiles = {
from : lDirPath + lFrom,
to : lDirPath + lTo
from = Cmd.getCurrentName(current),
to = Dialog.prompt('Rename', from) || from,
dirPath = Cmd.getCurrentDirPath();
cmp = Util.strCmp(from, to);
if (!cmp) {
files = {
from : dirPath + from,
to : dirPath + to
};
RESTful.mv(lFiles, function() {
DOM.setCurrentName(lTo, lCurrent);
RESTful.mv(files, function() {
var Storage = DOM.Storage,
path = CloudFunc.rmLastSlash(dirPath);
DOM.setCurrentName(to, current);
Storage.remove(path);
});
}
};