From 0c48e20d888a283e4a0c937ac39734715bb75d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Gonz=C3=A1lez=20Aravena?= Date: Tue, 15 Aug 2017 04:34:00 -0300 Subject: [PATCH] Fix test error --- lib/providers/filesystem/index.js | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/providers/filesystem/index.js b/lib/providers/filesystem/index.js index 6dcc5fd..8d0f038 100644 --- a/lib/providers/filesystem/index.js +++ b/lib/providers/filesystem/index.js @@ -124,22 +124,24 @@ FileSystemProvider.prototype.getContainers = function(cb) { FileSystemProvider.prototype.createContainer = function(options, cb) { var self = this; var name = options.name; - var hasSlash = (typeof name == 'string' ? name.search('%2F') : false); + var hasSlash = name.search('%2F'); name = (hasSlash != -1 ? name.replace(/%2F/gi, '/') : name); var dir = path.join(this.root, name); - validateName(name, cb) && fs.mkdir(dir, options, function(err) { - if (err) { - return cb && cb(err); + + mkdirp(dir, function(err) { + if(err) { + cb(err); + } else { + fs.stat(dir, function(err, stat) { + var container = null; + if(!err) { + var props = { name: name }; + populateMetadata(stat, props); + container = new Container(self, props); + } + cb(err, container); + }); } - fs.stat(dir, function(err, stat) { - var container = null; - if (!err) { - var props = {name: name}; - populateMetadata(stat, props); - container = new Container(self, props); - } - cb && cb(err, container); - }); }); }; @@ -182,7 +184,7 @@ FileSystemProvider.prototype.getContainer = function(containerName, cb) { // File related functions FileSystemProvider.prototype.upload = function(options, cb) { var container = options.container; - var hasSlash = (typeof container == 'string' ? container.search('%2F') : false); + var hasSlash = container.search('%2F'); container = (hasSlash != -1 ? container.replace(/%2F/gi, '/') : container); var file = options.remote; if (!validateName(file)) {