From 4d0fe3bf5d73df5f51eba1f0cd3f55c266e8362a Mon Sep 17 00:00:00 2001 From: James Allen Date: Wed, 23 Mar 2016 15:18:10 +0000 Subject: [PATCH] Add error handling in mkdir_p --- .../app/coffee/Features/Project/ProjectEntityHandler.coffee | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/web/app/coffee/Features/Project/ProjectEntityHandler.coffee b/services/web/app/coffee/Features/Project/ProjectEntityHandler.coffee index 946a57d527..02466d12b5 100644 --- a/services/web/app/coffee/Features/Project/ProjectEntityHandler.coffee +++ b/services/web/app/coffee/Features/Project/ProjectEntityHandler.coffee @@ -242,6 +242,7 @@ module.exports = ProjectEntityHandler = return folder.length != 0 ProjectGetter.getProjectWithOnlyFolders project_id, (err, project)=> + return callback(err) if err? if path == '/' logger.log project_id: project._id, "mkdir is only trying to make path of / so sending back root folder" return callback(null, [], project.rootFolder[0]) @@ -255,9 +256,11 @@ module.exports = ProjectEntityHandler = parentFolder_id = parentFolder._id builtUpPath = "#{builtUpPath}/#{folderName}" projectLocator.findElementByPath project, builtUpPath, (err, foundFolder)=> + return callback(err) if err? if !foundFolder? logger.log path:path, project_id:project._id, folderName:folderName, "making folder from mkdirp" @addFolder project_id, parentFolder_id, folderName, (err, newFolder, parentFolder_id)-> + return callback(err) if err? newFolder.parentFolder_id = parentFolder_id previousFolders.push newFolder callback null, previousFolders