From f98027e64bdbb7dc24622318639a0b25af769773 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 15 May 2018 16:33:11 +0300 Subject: [PATCH] fix(server) mv: rename file --- server/rest/index.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/server/rest/index.js b/server/rest/index.js index 9229740e..a24b0b6d 100644 --- a/server/rest/index.js +++ b/server/rest/index.js @@ -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);