mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
fix(dom) renameCurrent: try-to-promise RESTful.mv
This commit is contained in:
parent
6574d45939
commit
0b3348ee77
2 changed files with 23 additions and 10 deletions
|
|
@ -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();
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
11
common/try-to-promisify.js
Normal file
11
common/try-to-promisify.js
Normal 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);
|
||||
};
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue