From 188989a41202cf394ae40f344a5fb41d505f56ec Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 11 Sep 2014 15:04:19 +0000 Subject: [PATCH] feature(cloudcmd) fs: add realpath --- cloudcmd.js | 17 +++++++++++------ lib/server/rest.js | 9 +++++++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index 44cd1b09..f3f7c225 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -201,13 +201,18 @@ dir.path = format.addSlashToEnd(name); if (error) - if (error.code === 'ENOTDIR') { - p.name = path; - p.gzip = false; - ponse.sendFile(p); - } else { + if (error.code !== 'ENOTDIR') ponse.sendError(error, p); - } + else + fs.realpath(path, function(error, pathReal) { + if (!error) + p.name = pathReal; + else + p.name = path; + + p.gzip = false; + ponse.sendFile(p); + }); else buildIndex(dir, function(error, data) { var NOT_LOG = true; diff --git a/lib/server/rest.js b/lib/server/rest.js index 4d50542d..f773d592 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -161,8 +161,13 @@ }; if (isFile) { - params.gzip = false; - ponse.sendFile(params); + fs.realpath(path, function(error, path) { + if (!error) + params.name = path; + + params.gzip = false; + ponse.sendFile(params); + }); } else { if (!error) { data.path = format.addSlashToEnd(p.name);