fix(dom) renameCurrent: try-to-promise RESTful.mv

This commit is contained in:
coderaiser 2019-05-15 13:48:52 +03:00
parent 6574d45939
commit 0b3348ee77
2 changed files with 23 additions and 10 deletions

View file

@ -8,6 +8,7 @@ const jonny = require('jonny/legacy');
const tryToCatch = require('try-to-catch/legacy');
const Util = require('../../common/util');
const tryToPromisify = require('../../common/try-to-promisify');
const Images = require('./images');
const load = require('./load');
@ -763,6 +764,7 @@ function CmdProto() {
if (e)
return;
const isExist = !!DOM.getCurrentByName(to);
const dirPath = DOM.getCurrentDirPath();
@ -774,16 +776,16 @@ function CmdProto() {
to : dirPath + to,
};
RESTful.mv(files, (error) => {
if (error)
return;
DOM.setCurrentName(to, current);
Storage.remove(dirPath);
if (isExist)
CloudCmd.refresh();
});
const [error] = await tryToPromisify(RESTful.mv, files);
if (error)
return;
DOM.setCurrentName(to, current);
Storage.remove(dirPath);
if (isExist)
CloudCmd.refresh();
};
/**

View file

@ -0,0 +1,11 @@
'use strict';
const {promisify} = require('es6-promisify');
const tryToCatch = require('try-to-catch/legacy');
module.exports = (fn, ...args) => {
const promise = promisify(fn);
return tryToCatch(promise, ...args);
};