mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
fix(server) mv: rename file
This commit is contained in:
parent
c45ddd7c7c
commit
f98027e64b
1 changed files with 5 additions and 10 deletions
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
const DIR = '../';
|
||||
const DIR_COMMON = DIR + '../common/';
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const root = require(DIR + 'root');
|
||||
const config = require(DIR + 'config');
|
||||
|
|
@ -182,19 +184,12 @@ function onPUT(name, body, callback) {
|
|||
const to = root(files.to);
|
||||
const names = files.names;
|
||||
|
||||
if (names)
|
||||
return moveFiles(from, to, names)
|
||||
.on('error', fn)
|
||||
.on('end', fn);
|
||||
if (!names)
|
||||
return fs.rename(from, to, fn);
|
||||
|
||||
const dirname = path.dirname;
|
||||
const basename = path.basename;
|
||||
|
||||
moveFiles(dirname(from), dirname(to), [basename(to)])
|
||||
return moveFiles(from, to, names)
|
||||
.on('error', fn)
|
||||
.on('end', fn);
|
||||
|
||||
break;
|
||||
} case 'cp':
|
||||
if (!files.from || !files.names || !files.to)
|
||||
return callback(body);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue