mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-23 19:04:14 +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"
|
ProjectGetter = require "../Project/ProjectGetter"
|
||||||
UserGetter = require "../User/UserGetter"
|
UserGetter = require "../User/UserGetter"
|
||||||
DocumentUpdaterHandler = require('../DocumentUpdater/DocumentUpdaterHandler')
|
DocumentUpdaterHandler = require('../DocumentUpdater/DocumentUpdaterHandler')
|
||||||
U = require('underscore')
|
_ = require('underscore')
|
||||||
Async = require('async')
|
Async = require('async')
|
||||||
|
|
||||||
oneMinInMs = 60 * 1000
|
oneMinInMs = 60 * 1000
|
||||||
|
@ -22,24 +22,24 @@ module.exports = ReferencesHandler =
|
||||||
_findBibFileIds: (project) ->
|
_findBibFileIds: (project) ->
|
||||||
ids = []
|
ids = []
|
||||||
_process = (folder) ->
|
_process = (folder) ->
|
||||||
(folder.fileRefs or []).forEach (file) ->
|
_.each (folder.fileRefs or []), (file) ->
|
||||||
if file?.name?.match(/^.*\.bib$/)
|
if file?.name?.match(/^.*\.bib$/)
|
||||||
ids.push(file._id)
|
ids.push(file._id)
|
||||||
(folder.folders or []).forEach (folder) ->
|
_.each (folder.folders or []), (folder) ->
|
||||||
_process(folder)
|
_process(folder)
|
||||||
(project.rootFolder or []).forEach (rootFolder) ->
|
_.each (project.rootFolder or []), (rootFolder) ->
|
||||||
_process(rootFolder)
|
_process(rootFolder)
|
||||||
return ids
|
return ids
|
||||||
|
|
||||||
_findBibDocIds: (project) ->
|
_findBibDocIds: (project) ->
|
||||||
ids = []
|
ids = []
|
||||||
_process = (folder) ->
|
_process = (folder) ->
|
||||||
(folder.docs or []).forEach (doc) ->
|
_.each (folder.docs or []), (doc) ->
|
||||||
if doc?.name?.match(/^.*\.bib$/)
|
if doc?.name?.match(/^.*\.bib$/)
|
||||||
ids.push(doc._id)
|
ids.push(doc._id)
|
||||||
(folder.folders or []).forEach (folder) ->
|
_.each (folder.folders or []), (folder) ->
|
||||||
_process(folder)
|
_process(folder)
|
||||||
(project.rootFolder or []).forEach (rootFolder) ->
|
_.each (project.rootFolder or []), (rootFolder) ->
|
||||||
_process(rootFolder)
|
_process(rootFolder)
|
||||||
return ids
|
return ids
|
||||||
|
|
||||||
|
|
|
@ -322,6 +322,11 @@ describe 'ReferencesHandler', ->
|
||||||
result = @handler._findBibDocIds(@fakeProject)
|
result = @handler._findBibDocIds(@fakeProject)
|
||||||
expect(result).to.deep.equal @expectedIds
|
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', ->
|
describe '_findBibFileIds', ->
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
|
Loading…
Reference in a new issue