mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-23 15:12:17 +00:00
use underscore.each so it doesn’t blow up on non array.
This commit is contained in:
parent
18d0c51da9
commit
2ad0bab976
2 changed files with 12 additions and 7 deletions
|
@ -4,7 +4,7 @@ settings = require("settings-sharelatex")
|
|||
ProjectGetter = require "../Project/ProjectGetter"
|
||||
UserGetter = require "../User/UserGetter"
|
||||
DocumentUpdaterHandler = require('../DocumentUpdater/DocumentUpdaterHandler')
|
||||
U = require('underscore')
|
||||
_ = require('underscore')
|
||||
Async = require('async')
|
||||
|
||||
oneMinInMs = 60 * 1000
|
||||
|
@ -22,24 +22,24 @@ module.exports = ReferencesHandler =
|
|||
_findBibFileIds: (project) ->
|
||||
ids = []
|
||||
_process = (folder) ->
|
||||
(folder.fileRefs or []).forEach (file) ->
|
||||
_.each (folder.fileRefs or []), (file) ->
|
||||
if file?.name?.match(/^.*\.bib$/)
|
||||
ids.push(file._id)
|
||||
(folder.folders or []).forEach (folder) ->
|
||||
_.each (folder.folders or []), (folder) ->
|
||||
_process(folder)
|
||||
(project.rootFolder or []).forEach (rootFolder) ->
|
||||
_.each (project.rootFolder or []), (rootFolder) ->
|
||||
_process(rootFolder)
|
||||
return ids
|
||||
|
||||
_findBibDocIds: (project) ->
|
||||
ids = []
|
||||
_process = (folder) ->
|
||||
(folder.docs or []).forEach (doc) ->
|
||||
_.each (folder.docs or []), (doc) ->
|
||||
if doc?.name?.match(/^.*\.bib$/)
|
||||
ids.push(doc._id)
|
||||
(folder.folders or []).forEach (folder) ->
|
||||
_.each (folder.folders or []), (folder) ->
|
||||
_process(folder)
|
||||
(project.rootFolder or []).forEach (rootFolder) ->
|
||||
_.each (project.rootFolder or []), (rootFolder) ->
|
||||
_process(rootFolder)
|
||||
return ids
|
||||
|
||||
|
|
|
@ -322,6 +322,11 @@ describe 'ReferencesHandler', ->
|
|||
result = @handler._findBibDocIds(@fakeProject)
|
||||
expect(result).to.deep.equal @expectedIds
|
||||
|
||||
it 'should not error with a non array of folders from dirty data', ->
|
||||
@fakeProject.rootFolder[0].folders[0].folders = {}
|
||||
result = @handler._findBibDocIds(@fakeProject)
|
||||
expect(result).to.deep.equal @expectedIds
|
||||
|
||||
describe '_findBibFileIds', ->
|
||||
|
||||
beforeEach ->
|
||||
|
|
Loading…
Reference in a new issue