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)) {