null check folder in findElement

https://sentry.io/sharelatex-1/sl-web-server-prod/issues/236000085/
This commit is contained in:
Henry Oswald 2017-03-17 13:29:09 +00:00
parent 31b1c53faa
commit 8ee2e5ba63
2 changed files with 3 additions and 1 deletions

View file

@ -26,6 +26,8 @@ module.exports = ProjectLocator =
element = _.find searchFolder[elementType], (el)-> el?._id+'' == element_id+'' #need to ToString both id's for robustness
if !element? && searchFolder.folders? && searchFolder.folders.length != 0
_.each searchFolder.folders, (folder, index)->
if !folder?
return
newPath = {}
newPath[key] = value for own key,value of path #make a value copy of the string
newPath.fileSystem += "/#{folder.name}"

View file

@ -17,7 +17,7 @@ file1 = name:"file1", _id:"dsa9lkdsad"
subSubFile = name:"subSubFile", _id:"d1d2dk"
subSubDoc = name:"subdoc.txt", _id:"321dmdwi"
secondSubFolder = name:"secondSubFolder", _id:"dsa3e23", docs:[subSubDoc], fileRefs:[subSubFile], folders:[]
subFolder = name:"subFolder", _id:"dsadsa93", folders:[secondSubFolder], docs:[], fileRefs:[]
subFolder = name:"subFolder", _id:"dsadsa93", folders:[secondSubFolder, null], docs:[], fileRefs:[]
subFolder1 = name:"subFolder1", _id:"123asdjoij"
rootFolder =